Modify: 所有function的return值改為http post的response

This commit is contained in:
dennis 2023-09-12 22:39:13 +08:00
parent cd8bbde1af
commit 10c8754732

View File

@ -78,7 +78,7 @@ func (f *FeeAuditUtils) getChecksum(apData string) string {
}
// httpsPost 用來上傳 WriteoffResponse
func (f *FeeAuditUtils) httpsPost(funcName string, writeoffRequest WriteoffRequest) (writeoffResponse WriteoffResponse, err error) {
func (f *FeeAuditUtils) httpsPost(funcName string, writeoffRequest WriteoffRequest) (responseData []byte, err error) {
data, err := json.Marshal(&writeoffRequest)
if err != nil {
return
@ -108,14 +108,7 @@ func (f *FeeAuditUtils) httpsPost(funcName string, writeoffRequest WriteoffReque
}
defer response.Body.Close()
responseData, err := io.ReadAll(response.Body)
if err != nil {
return
}
err = json.Unmarshal(responseData, &writeoffResponse)
return
return io.ReadAll(response.Body)
}
// NewRequest 用來産生 WirteoffRequest
@ -134,57 +127,31 @@ func (f *FeeAuditUtils) NewRequest(data []byte) WriteoffRequest {
}
// SendFeeApply 傳送服務記錄申報
func (f *FeeAuditUtils) SendFeeApply(writeoffRequest WriteoffRequest) (writeoffResponse WriteoffResponse, feeApplyResult FeeApplyResult, err error) {
writeoffResponse, err = f.httpsPost("FeeApply", writeoffRequest)
if err != nil {
return
}
resultData, err := base64.StdEncoding.DecodeString(writeoffResponse.Result)
err = json.Unmarshal(resultData, &feeApplyResult)
return
func (f *FeeAuditUtils) SendFeeApply(writeoffRequest WriteoffRequest) (responseData []byte, err error) {
return f.httpsPost("FeeApply", writeoffRequest)
}
// SendObjDel 傳送服務紀錄刪除
func (f *FeeAuditUtils) SendObjDel(writeoffRequest WriteoffRequest) (writeoffResponse WriteoffResponse, err error) {
writeoffResponse, err = f.httpsPost("ObjDel", writeoffRequest)
return
func (f *FeeAuditUtils) SendObjDel(writeoffRequest WriteoffRequest) (responseData []byte, err error) {
return f.httpsPost("ObjDel", writeoffRequest)
}
// SendAppCompletionNotice 傳送申報確認通知
func (f *FeeAuditUtils) SendAppCompletionNotice(writeoffRequest WriteoffRequest) (writeoffResponse WriteoffResponse, err error) {
writeoffResponse, err = f.httpsPost("appCompletionNotice", writeoffRequest)
return
func (f *FeeAuditUtils) SendAppCompletionNotice(writeoffRequest WriteoffRequest) (responseData []byte, err error) {
return f.httpsPost("appCompletionNotice", writeoffRequest)
}
// SendAppResultQuery 傳送「服務單位各分案審核狀態查詢」或「分案審核明細查詢」
func (f *FeeAuditUtils) SendAppResultQuery(writeoffRequest WriteoffRequest) (writeoffResponse WriteoffResponse, appResultQueryResult AppResultQueryResult, err error) {
writeoffResponse, err = f.httpsPost("appResultQuery", writeoffRequest)
if err != nil {
return
}
resultData, err := base64.StdEncoding.DecodeString(writeoffResponse.Result)
err = json.Unmarshal(resultData, &appResultQueryResult)
return
func (f *FeeAuditUtils) SendAppResultQuery(writeoffRequest WriteoffRequest) (responseData []byte, err error) {
return f.httpsPost("appResultQuery", writeoffRequest)
}
// SendAppCancel 傳送撤回服務記錄
func (f *FeeAuditUtils) SendAppCancel(writeoffRequest WriteoffRequest) (writeoffResponse WriteoffResponse, err error) {
writeoffResponse, err = f.httpsPost("appCancel", writeoffRequest)
return
func (f *FeeAuditUtils) SendAppCancel(writeoffRequest WriteoffRequest) (responseData []byte, err error) {
return f.httpsPost("appCancel", writeoffRequest)
}
// SendCancelResultResponse 傳送取消交易單處理結果回報
func (f *FeeAuditUtils) SendCancelResultResponse(writeoffRequest WriteoffRequest) (writeoffResponse WriteoffResponse, err error) {
writeoffResponse, err = f.httpsPost("CancelResultResponse", writeoffRequest)
return
func (f *FeeAuditUtils) SendCancelResultResponse(writeoffRequest WriteoffRequest) (responseData []byte, err error) {
return f.httpsPost("CancelResultResponse", writeoffRequest)
}