welcome_text.go 865 Bytes
Newer Older
hujiebin's avatar
hujiebin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
package group_s

import (
	"git.hilo.cn/hilo-common/domain"
	"hilo-group/_const/enum/msg_e"
	"hilo-group/domain/model/group_m"
	"hilo-group/domain/model/res_m"
)

func (s *GroupService) GetWelcomeText(groupInfo *group_m.GroupInfo) (string, uint64, bool, error) {
	model := domain.CreateModelContext(s.svc.MyContext)

	g := group_m.GroupWelcomeText{GroupId: groupInfo.ImGroupId}
	gwt, err := g.Get(model.Db)
	if err != nil {
		return "", 0, false, err
	}

	if gwt == nil {
		// 通过国家推断语言
		lang, err := res_m.GetLangeByCountry(model.Db, groupInfo.Country)
		if err != nil {
			return "", 0, false, err
		}

		resMul, err := res_m.GetResMultiTextBy(model.Db, msg_e.MSG_ID_GROUP_WELCOME, lang)
		if err != nil {
			return "", 0, false, err
		}
		return resMul.Content, groupInfo.Owner, true, nil
	} else {
		return gwt.Text, gwt.UserId, false, nil
	}
}