chance_check_result.go 1.4 KB
package models

import (
	"time"

	"github.com/astaxie/beego/orm"
)

type ChanceCheckResult struct {
	Id            int64     `orm:"column(id);auto"`
	ChanceId      int64     `orm:"column(chance_id)"`
	GroupId       int64     `orm:"column(group_id);null"`
	CheckPid      int64     `orm:"column(check_pid)"`
	CheckId       int64     `orm:"column(check_id)"`
	CheckItem     string    `orm:"column(check_item);size(20);null" description:"检查项"`
	Answer        string    `orm:"column(answer);size(50);null" description:"回答"`
	Reason        string    `orm:"column(reason);size(200);null" description:"理由"`
	UserCompanyId int64     `orm:"column(user_company_id);null"`
	CreateAt      time.Time `orm:"column(create_at);type(timestamp);null"`
}

func (t *ChanceCheckResult) TableName() string {
	return "chance_check_result"
}

func init() {
	orm.RegisterModel(new(ChanceCheckResult))
}

// GetChanceCheckResultById retrieves ChanceCheckResult by Id. Returns error if
// Id doesn't exist
func GetChanceCheckResultById(id int64) (v *ChanceCheckResult, err error) {
	o := orm.NewOrm()
	v = &ChanceCheckResult{Id: id}
	if err = o.Read(v); err == nil {
		return v, nil
	}
	return nil, err
}

func GetChanceCheckResultByChancce(chanceId int64) ([]ChanceCheckResult, error) {
	var (
		err  error
		data []ChanceCheckResult
	)
	o := orm.NewOrm()
	_, err = o.QueryTable(&ChanceCheckResult{}).
		Filter("chance_id", chanceId).
		All(&data)
	return data, err
}