60 lines
2.0 KiB
Go
60 lines
2.0 KiB
Go
package cast
|
|
|
|
import (
|
|
"fmt"
|
|
"fonchain-fiee/api/cast"
|
|
modelCast "fonchain-fiee/pkg/model/cast"
|
|
"strings"
|
|
|
|
"github.com/360EntSecGroup-Skylar/excelize"
|
|
)
|
|
|
|
type Work struct {
|
|
}
|
|
|
|
func (w *Work) ExportExcelWorkList(data []*cast.WorkListResp_Info) (*excelize.File, error) {
|
|
f := excelize.NewFile()
|
|
sheetName := "Sheet1"
|
|
f.SetSheetName("Sheet1", sheetName)
|
|
|
|
headers := []string{
|
|
"艺人", "艺人手机号", "作品标题", "作品类型", "类型", "发布平台", "提交时间", "作品状态", "发布账号", "管理人",
|
|
}
|
|
for i, h := range headers {
|
|
cell := fmt.Sprintf("%s%d", string(rune('A'+i)), 1)
|
|
f.SetCellValue(sheetName, cell, h)
|
|
}
|
|
|
|
rowIndex := 2
|
|
for _, info := range data {
|
|
var platformNames string
|
|
for _, v := range info.PlatformIDs {
|
|
platformNames += modelCast.PlatformIDMM[int(v)] + "/"
|
|
}
|
|
platformNames = strings.Trim(platformNames, "/")
|
|
var ManagerUserNames string
|
|
for _, v := range info.ManagerUserNames {
|
|
ManagerUserNames += v + "/"
|
|
}
|
|
ManagerUserNames = strings.Trim(ManagerUserNames, "/")
|
|
var mediaAccountNames string
|
|
for _, v := range info.MediaAccountNames {
|
|
mediaAccountNames += v + "/"
|
|
}
|
|
mediaAccountNames = strings.Trim(mediaAccountNames, "/")
|
|
f.SetCellValue(sheetName, fmt.Sprintf("A%d", rowIndex), info.ArtistName)
|
|
f.SetCellValue(sheetName, fmt.Sprintf("B%d", rowIndex), info.ArtistPhone)
|
|
f.SetCellValue(sheetName, fmt.Sprintf("C%d", rowIndex), info.Title)
|
|
f.SetCellValue(sheetName, fmt.Sprintf("D%d", rowIndex), modelCast.WorkCategoryMM[int(info.WorkCategory)])
|
|
f.SetCellValue(sheetName, fmt.Sprintf("E%d", rowIndex), modelCast.WorkCostTypeMM[int(info.CostType)])
|
|
f.SetCellValue(sheetName, fmt.Sprintf("F%d", rowIndex), platformNames)
|
|
f.SetCellValue(sheetName, fmt.Sprintf("G%d", rowIndex), info.SubmitTime)
|
|
f.SetCellValue(sheetName, fmt.Sprintf("H%d", rowIndex), modelCast.WorkStatusMM[int(info.WorkStatus)])
|
|
f.SetCellValue(sheetName, fmt.Sprintf("I%d", rowIndex), mediaAccountNames)
|
|
f.SetCellValue(sheetName, fmt.Sprintf("J%d", rowIndex), ManagerUserNames)
|
|
rowIndex++
|
|
}
|
|
|
|
return f, nil
|
|
}
|