service.go 829 字节
package service

import (
	"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/unifiedUserCenter/command"
)

//PlatformAction 企业平台数据同步服务 动作接口设定
type SyncAction interface {
	DoAction(string, []byte) error
}

//actionMap 数据同步需要的动作集合,静态不要在运行时变更这里的数据
//position:职位,department:部门,employee:员工,company:公司
var actionMap = map[string]SyncAction{
	// "department":
	// "position":
	"employee": SyncEmployeeService{},
	"company":  SyncCompanyService{},
}

func NewSyncAction(cmd command.SyncCallbackCommand) error {
	err := cmd.ValidateCommand()
	if err != nil {
		return err
	}
	var (
		action SyncAction
		ok     bool
	)
	if action, ok = actionMap[cmd.Module]; !ok {
		return nil
	}
	return action.DoAction(cmd.Action, cmd.Data)
}