/*
 * @description:项目用户数据库操作
 * @Author: CP
 * @Date: 2020-08-31 15:57:04
 * @FilePath: \construction_management\dao\project_account_dao.go
 */
package dao

import (
	"github.com/go-xorm/xorm"
	"go.mod/models"
)

//数据库操作引擎
type ProjectAccountDao struct {
	engine *xorm.Engine
}

//获得一个DAO对象
func NewProjectAccountDao(engine *xorm.Engine) *ProjectAccountDao {
	return &ProjectAccountDao{
		engine: engine,
	}
}

//CmProjectAccount 设置的值获得数据
func (d *ProjectAccountDao) GetOne(data *models.CmProjectAccount) *models.CmProjectAccount {
	//data := data
	//Get取到值后，会自动赋值到data中
	ok, err := d.engine.Get(data)
	if ok && err == nil {
		return data
	} else {
		data.Id = 0
		return data
	}
}

//id获得数据
func (d *ProjectAccountDao) Get(id int) *models.CmProjectAccount {
	data := &models.CmProjectAccount{Id: id}
	//Get取到值后，会自动赋值到data中
	ok, err := d.engine.Get(data)
	if ok && err == nil {
		return data
	} else {
		data.Id = 0
		return data
	}
}
