/*
 * @description:项目用户相关数据处理
 * @Author: CP
 * @Date: 2020-08-27 17:23:58
 * @FilePath: \construction_management\services\project_account_service.go
 */
package services

import (
	"errors"

	"go.mod/models"

	"go.mod/dao"
	"go.mod/datasource"
)

//定义项目用户Service接口
type ProjectAccountService interface {
	ValidManager(code string, account string, password string) error
}

//返回service操作类
type projectAccountService struct {
	dao *dao.ProjectAccountDao
}

//创建项目用户service
func NewProjectAccountService() ProjectAccountService {
	return &projectAccountService{
		dao: dao.NewProjectAccountDao(datasource.InstanceDbMaster()),
	}
}

//实现getall接口
func (s *projectAccountService) ValidManager(code string, account string, password string) error {

	//先拿到项目信息

	//获得项目用户

	// 验证密码

	// 生成数字证书

	// 加密用户标识

	// 设置cookie

	// TODO--分布式会话--后续需要在加入

	projectAccountInfo := models.CmProjectAccount{}
	//projectAccountInfo.ProjectId = data.Id
	projectAccountInfo.Account = account

	s.dao.GetOne(&projectAccountInfo)

	return errors.New("test custom err")
}
