package service import ( "xps/cmd/datasource" "xps/pkg/biz/datamodel" "xps/pkg/biz/repository" "xps/pkg/biz/viewmodel" "xps/pkg/common" ) type BizObjectService interface { GetList(m map[string]interface{}) ([]viewmodel.BizObjectInfo, error) GetPage(m map[string]interface{}) (*common.PageResult, error) GetById(bizId, objectId int64) (*viewmodel.BizObjectInfo, error) GetListById(bizId int64) ([]viewmodel.BizObjectInfo, error) Create(d *datamodel.BizObject) error Update(d *datamodel.BizObject) error Delete(m map[string]interface{}) error } type bizObjectService struct { bizObjectRepo *repository.BizObjectRepo bizObjectAttrRepo *repository.BizObjectAttrRepo } func NewBizObjectService() BizObjectService { return &bizObjectService{ bizObjectRepo: repository.NewBizObjectRepo(datasource.InstanceMaster()), bizObjectAttrRepo: repository.NewBizObjectAttrRepo(datasource.InstanceMaster()), } } func (s *bizObjectService) GetList(m map[string]interface{}) ([]viewmodel.BizObjectInfo, error) { return s.bizObjectRepo.GetList(m) } func (s *bizObjectService) GetListById(bizId int64) ([]viewmodel.BizObjectInfo, error) { return s.bizObjectRepo.GetListById(bizId) } func (s *bizObjectService) GetPage(m map[string]interface{}) (*common.PageResult, error) { return s.bizObjectRepo.GetPage(m) } func (s *bizObjectService) GetById(bizId, objectId int64) (*viewmodel.BizObjectInfo, error) { return s.bizObjectRepo.GetById(bizId, objectId) } func (s *bizObjectService) Create(o *datamodel.BizObject) error { objectId := NewID() o.ObjectId = objectId return s.bizObjectRepo.Create(o) } func (s *bizObjectService) Update(o *datamodel.BizObject) error { return s.bizObjectRepo.Update(o) } func (s *bizObjectService) Delete(m map[string]interface{}) error { bizId := m["bizId"].(int64) objectId := m["objectId"].(int64) err := s.bizObjectRepo.Delete(m) if err != nil { return err } return s.bizObjectAttrRepo.DeleteByObjectId(bizId, objectId) }