// application is app who will use the cloud api
package models

import (
	"errors"

	"github.com/jinzhu/gorm"
)

// Application 代指一个应用程序
type Application struct {
	gorm.Model
	// App-Key for api
	AppKey string `sql:"type:varchar(200);not null;"`
	// App-Token for web hook
	AppToken string `sql:"type:varchar(200);not null;"`
	// Report Url for web hook
	ReportUrl string `sql:"type:varchar(200);not null;"`
	// name
	AppName string `sql:"type:varchar(200);"`
	// desc
	AppDescription string `sql:"type:text;"`
	// app domain which allows wildcard string like "*", "vendor/12", "product/10"
	AppDomain string `sql:"type:varchar(200);not null;"`
	// vendor id
	VendorID uint
}

// Validate 验证规则
func (a *Application) Validate() error {
	if a.AppName == "" {
		return errors.New("非法参数:[AppName]")
	}
	return nil
}
