/*
 * @description:版本相关数据操作
 * @Author: CP
 * @Date: 2020-09-02 09:56:28
 * @FilePath: \construction_management\services\version_service.go
 */
package services

import (
	"go.mod/dao"
	"go.mod/datasource"
	"go.mod/web/viewmodels"
)

//定义项目用户Service接口
type VersionService interface {
	Get() *viewmodels.Version
}

//返回service操作类
type versionService struct {
	versionDao *dao.VersionDao
}

//创建项目用户service
func NewVersionService() VersionService {
	return &versionService{
		versionDao: dao.NewVersionDao(datasource.InstanceDbMaster()),
	}
}

// 验证项目用户登陆相关
func (s *versionService) Get() *viewmodels.Version {

	// 1-1.工程项目是否存在
	versionData := s.versionDao.Get()
	if versionData.Id == 0 {
		return nil
	}
	versionVm := &viewmodels.Version{}
	versionVm.Name = versionData.Name
	return versionVm
}
