package business_trip

import "time"

import (
	"github.com/beego/beego/v2/client/orm"
)

type BusinessApplyPeer struct {
	BusinessApplyPeerId int       `orm:"column(business_apply_peer_id);pk;auto" description:"ID"`
	BusinessApplyId     int       `description:"出差申请id"`
	ArriveDate          string    `description:"到达日期"`
	ReturnDate          string    `description:"返程日期"`
	Province            string    `description:"目的地省"`
	City                string    `description:"目的地市"`
	Status              string    `description:"状态:'待审批','已审批','已驳回','已撤回','已过期'"`
	PeerPeopleId        int       `description:"同行人id"`
	PeerPeopleName      string    `description:"同行人姓名"`
	CreateTime          time.Time `description:"创建时间"`
	ModifyTime          time.Time `description:"修改时间"`
}

// 添加出差申请随行人
func AddBusinessApplyPeer(items []*BusinessApplyPeer) (err error) {
	o := orm.NewOrm()
	_, err = o.InsertMulti(len(items), items)
	if err != nil {
		return
	}
	return
}

// 删除
func DeleteBusinessApplyPeer(businessApplyId int) (err error) {
	o := orm.NewOrm()
	sql := ` DELETE FROM business_apply_peer WHERE business_apply_id=? `
	_, err = o.Raw(sql, businessApplyId).Exec()
	if err != nil {
		return err
	}
	return err
}
