@@ -53,14 +53,15 @@ func (app *application) showTenantsHandler(c echo.Context) error {
5353func (app * application ) createTenantHandler (c echo.Context ) error {
5454
5555 var input struct {
56- FirstName string `json:"first_name" validate:"required"`
57- LastName string `json:"last_name" validate:"required"`
58- Phone string `json:"phone" validate:"required,len=10"`
59- HouseId uuid.UUID `json:"house_id" validate:"required"`
60- PersonalIdType string `json:"personal_id_type" validate:"required"`
61- PersonalId string `json:"personal_id" validate:"required"`
62- Active bool `json:"active"`
63- Sos time.Time `json:"sos" validate:"required"`
56+ FirstName string `json:"first_name" validate:"required"`
57+ LastName string `json:"last_name" validate:"required"`
58+ Phone string `json:"phone" validate:"required,len=10"`
59+ HouseId uuid.UUID `json:"house_id" validate:"required"`
60+ PersonalIdType string `json:"personal_id_type" validate:"required"`
61+ PersonalId string `json:"personal_id" validate:"required"`
62+ Active bool `json:"active"`
63+ Sos time.Time `json:"sos" validate:"required"`
64+ Eos * time.Time `json:"eos"`
6465 }
6566
6667 if err := c .Bind (& input ); err != nil {
@@ -71,6 +72,14 @@ func (app *application) createTenantHandler(c echo.Context) error {
7172 return c .JSON (http .StatusBadRequest , envelope {"error" : err .Error ()})
7273 }
7374
75+ var eos time.Time
76+
77+ if input .Eos == nil {
78+ eos = input .Sos .AddDate (0 , 2 , 0 )
79+ } else {
80+ eos = * input .Eos
81+ }
82+
7483 house , err := app .store .GetHouseById (c .Request ().Context (), input .HouseId )
7584
7685 if err != nil {
@@ -101,6 +110,7 @@ func (app *application) createTenantHandler(c echo.Context) error {
101110 PersonalID : input .PersonalId ,
102111 Active : input .Active ,
103112 Sos : input .Sos ,
113+ Eos : eos ,
104114 }
105115
106116 err = app .store .TxnCreateTenant (c .Request ().Context (), args )
0 commit comments