| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package service
- import (
- "xps/datamodel"
- "xps/datasource"
- "xps/repositories"
- "xps/viewmodel"
- )
- type AppService interface {
- GetList(m map[string]interface{}) ([]viewmodel.AppInfo, error)
- GetPage(m map[string]interface{}) (*viewmodel.PageResult, error)
- GetById(appId int64) (*viewmodel.AppInfo, error)
- Create(d *datamodel.App) error
- Update(d *datamodel.App) error
- Delete(m map[string]interface{}) error
- GetPermit(roleId int64, appKey string) ([]viewmodel.AppPermitInfo, error)
- }
- type appService struct {
- appRepo *repositories.AppRepo
- appPermitRepo *repositories.AppPermitRepo
- }
- func NewAppService() AppService {
- return &appService{
- appRepo: repositories.NewAppRepo(datasource.InstanceMaster()),
- appPermitRepo: repositories.NewAppPermitRepo(datasource.InstanceMaster()),
- }
- }
- func (s *appService) GetList(m map[string]interface{}) ([]viewmodel.AppInfo, error) {
- return s.appRepo.GetList(m)
- }
- func (s *appService) GetPage(m map[string]interface{}) (*viewmodel.PageResult, error) {
- return s.appRepo.GetPage(m)
- }
- func (s *appService) GetById(appId int64) (*viewmodel.AppInfo, error) {
- return s.appRepo.GetById(appId)
- }
- func (s *appService) Create(App *datamodel.App) error {
- App.AppId = NewID()
- return s.appRepo.Create(App)
- }
- func (s *appService) Update(App *datamodel.App) error {
- return s.appRepo.Update(App)
- }
- func (s *appService) Delete(m map[string]interface{}) error {
- return s.appRepo.Delete(m)
- }
- func (s *appService) GetPermit(roleId int64, appKey string) ([]viewmodel.AppPermitInfo, error) {
- m := make(map[string]interface{}, 0)
- m["appKey"] = appKey
- m["roleId"] = roleId
- return s.appPermitRepo.GetList(m)
- }
|