create_group.go 681 Bytes
Newer Older
chenweijian's avatar
chenweijian committed
1 2 3 4 5 6
package group_cron

import (
	"git.hilo.cn/hilo-common/domain"
	"git.hilo.cn/hilo-common/resource/config"
	"github.com/robfig/cron"
chenweijian's avatar
chenweijian committed
7
	"hilo-group/_const/enum/group_e"
chenweijian's avatar
chenweijian committed
8 9 10 11 12 13 14 15
	"hilo-group/domain/service/group_s"
)

func CreateGroup() {
	if !config.IsMaster() {
		return
	}
	c := cron.New()
chenweijian's avatar
chenweijian committed
16
	spec := "0 15 15 16 8 ?"
chenweijian's avatar
chenweijian committed
17 18 19
	_ = c.AddFunc(spec, func() {
		var model = domain.CreateModelNil()
		userId := uint64(7687)
chenweijian's avatar
chenweijian committed
20
		num := 20
chenweijian's avatar
chenweijian committed
21
		if config.AppIsRelease() {
chenweijian's avatar
chenweijian committed
22
			userId = 8350311
chenweijian's avatar
chenweijian committed
23
			num = 1000
chenweijian's avatar
chenweijian committed
24
		}
chenweijian's avatar
chenweijian committed
25
		err := group_s.NewGroupService(model.MyContext).CreateGroupMulByUid(userId, num, group_e.TwoMicNumType)
chenweijian's avatar
chenweijian committed
26 27 28 29 30 31 32
		if err != nil {
			model.Log.Errorf("CreateGroupMulByUid fail:%v", err)
		}
	})

	c.Start()
}