biz_rule_service.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package service
  2. import (
  3. "xps/cmd/datasource"
  4. "xps/pkg/biz/datamodel"
  5. "xps/pkg/biz/repository"
  6. "xps/pkg/biz/viewmodel"
  7. "xps/pkg/common"
  8. )
  9. type BizRuleService interface {
  10. GetList(m map[string]interface{}) ([]viewmodel.BizRuleInfo, error)
  11. GetPage(m map[string]interface{}) (*common.PageResult, error)
  12. GetById(ruleId int64) (*viewmodel.BizRuleInfo, error)
  13. Create(d *datamodel.BizRule) error
  14. Update(d *datamodel.BizRule) error
  15. Delete(m map[string]interface{}) error
  16. }
  17. type bizRuleService struct {
  18. repo *repository.BizRuleRepo
  19. }
  20. func NewBizRuleService() BizRuleService {
  21. return &bizRuleService{
  22. repo: repository.NewBizRuleRepo(datasource.InstanceMaster()),
  23. }
  24. }
  25. func (s *bizRuleService) GetList(m map[string]interface{}) ([]viewmodel.BizRuleInfo, error) {
  26. return s.repo.GetList(m)
  27. }
  28. func (s *bizRuleService) GetPage(m map[string]interface{}) (*common.PageResult, error) {
  29. return s.repo.GetPage(m)
  30. }
  31. func (s *bizRuleService) GetById(ruleId int64) (*viewmodel.BizRuleInfo, error) {
  32. return s.repo.GetById(ruleId)
  33. }
  34. func (s *bizRuleService) Create(m *datamodel.BizRule) error {
  35. m.RuleId = NewID()
  36. return s.repo.Create(m)
  37. }
  38. func (s *bizRuleService) Update(m *datamodel.BizRule) error {
  39. return s.repo.Update(m)
  40. }
  41. func (s *bizRuleService) Delete(m map[string]interface{}) error {
  42. return s.repo.Delete(m)
  43. }