generated from VLADIMIR/template
add application number
This commit is contained in:
@@ -1,11 +1,34 @@
|
||||
package models
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Application struct {
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name"`
|
||||
Number string `json:"-"`
|
||||
}
|
||||
|
||||
func NewApplication(name string) *Application {
|
||||
return &Application{
|
||||
func NewApplication(
|
||||
name string,
|
||||
opts ...ApplicationOpt,
|
||||
) *Application {
|
||||
application := &Application{
|
||||
Name: name,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(application)
|
||||
}
|
||||
return application
|
||||
}
|
||||
|
||||
type ApplicationOpt func(application *Application) error
|
||||
|
||||
func WithApplicationNumber(number int) ApplicationOpt {
|
||||
return func(application *Application) error {
|
||||
application.SetNumber(number)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Application) SetNumber(number int) {
|
||||
a.Number = fmt.Sprintf("%d", number)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user