/*
 * @description:消息推送
 * @Author: LanJianRong
 * @Date: 2021-01-26 14:40:06
 * @FilePath: \construction_management\dao\project_message_dao.go
 */
package dao

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

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

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

// 获得项目下 账号的消息
func (d *ProjectMessageDao) GetAll(projectId int, accountId int) []viewmodels.ProjectMessageVM {

	datalist := make([]viewmodels.ProjectMessageVM, 0)
	_ = d.engine.SQL("select pm.*, b.name as bidsection_name from cm_project_message as pm left join cm_bidsection as b on b.id = pm.bidsection_id where pm.project_id=? and pm.account_id=? order by pm.id desc limit 10", projectId, accountId).Find(&datalist)
	return datalist
}
