service.go
870 字节
package service
import (
"errors"
"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 errors.New("module cannot found")
}
return action.DoAction(cmd.Action, cmd.Data)
}