package conv

import (
	"gadmin/package/gmdata"
	"gadmin/utility"
	"github.com/sirupsen/logrus"
)

var Activity = new(cActivity)

type cActivity struct {
	version string
	lst     []*gmdata.Role
}

func (j *cActivity) Extract(version string) {
	logrus.Info("cActivity Extract...")
	j.setVersion(version).save()
}

func (j *cActivity) setVersion(version string) *cActivity {
	j.version = version
	return j
}

func (j *cActivity) save() {
	// 下载的文件列表
	downs := []string{"activity.json", "Activity2.json"}
	for _, fileName := range downs {

		// 保存文件
		url := utility.PullJsonAddr(j.version, fileName)
		dstFileName := utility.LocalJsonPath(j.version, fileName)
		if err := HttpRequestToFile(url, dstFileName); err != nil {
			logrus.Info("HttpRequestToFile err:%+v", err)
			return
		}
	}
}
