40 lines
954 B
Go
40 lines
954 B
Go
|
package cast
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"errors"
|
||
|
"fmt"
|
||
|
"fonchain-fiee/cmd/config"
|
||
|
"fonchain-fiee/pkg/e"
|
||
|
"fonchain-fiee/pkg/utils"
|
||
|
modelCast "fonchain-fiee/pkg/model/cast"
|
||
|
)
|
||
|
|
||
|
type CastService struct {
|
||
|
}
|
||
|
|
||
|
func (c *CastService) ApprovalDetail(approvalIds []int) (data map[int]int, err error) {
|
||
|
idsBytes, _ := json.Marshal(approvalIds)
|
||
|
var respBody string
|
||
|
url := fmt.Sprintf(config.AppConfig.System.ErpHost + "/approval/list/ex")
|
||
|
respBody, err = utils.Post(url, string(idsBytes))
|
||
|
if err != nil {
|
||
|
return
|
||
|
}
|
||
|
var respDetail modelCast.ApprovalDetailResponse
|
||
|
if err = json.Unmarshal([]byte(respBody), &respDetail); err != nil {
|
||
|
err = errors.New(e.GetMsg(e.JsonUnmarshal))
|
||
|
return
|
||
|
}
|
||
|
if respDetail.Status == 0 && len(respDetail.Data.Data) > 0 {
|
||
|
data = make(map[int]int, len(respDetail.Data.Data))
|
||
|
for _, v := range respDetail.Data.Data {
|
||
|
data[v.ID] = v.Status
|
||
|
}
|
||
|
} else {
|
||
|
err = errors.New(e.GetMsg(e.ErrorHttp))
|
||
|
return
|
||
|
}
|
||
|
return
|
||
|
}
|