46 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package cast
 | |
| 
 | |
| import (
 | |
| 	"encoding/json"
 | |
| 	"errors"
 | |
| 	"fmt"
 | |
| 	"fonchain-fiee/cmd/config"
 | |
| 	"fonchain-fiee/pkg/e"
 | |
| 	modelCast "fonchain-fiee/pkg/model/cast"
 | |
| 	"fonchain-fiee/pkg/utils"
 | |
| )
 | |
| 
 | |
| type CastService struct {
 | |
| }
 | |
| 
 | |
| func (c *CastService) ApprovalDetail(approvalIds []int) (data map[int]modelCast.Item, err error) {
 | |
| 	type ApprovalDetailRequest struct {
 | |
| 		ID []int `json:"ID"`
 | |
| 	}
 | |
| 	req := ApprovalDetailRequest{
 | |
| 		ID: approvalIds,
 | |
| 	}
 | |
| 	idsBytes, _ := json.Marshal(req)
 | |
| 	var respBody string
 | |
| 	url := fmt.Sprintf(config.AppConfig.System.FieeHost + "/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]modelCast.Item, len(respDetail.Data.Data))
 | |
| 		for _, v := range respDetail.Data.Data {
 | |
| 			data[v.ID] = v
 | |
| 		}
 | |
| 	} else {
 | |
| 		err = errors.New(e.GetMsg(e.ErrorHttp))
 | |
| 		return
 | |
| 	}
 | |
| 	return
 | |
| }
 |