128 lines
3.3 KiB
Go
128 lines
3.3 KiB
Go
package vo
|
|
|
|
import (
|
|
"electricity_bill_calc/model"
|
|
"electricity_bill_calc/types"
|
|
"time"
|
|
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
type MGTAndOPSAccountCreationForm struct {
|
|
Username string `json:"username"`
|
|
Name string `json:"name"`
|
|
Contact *string `json:"contact"`
|
|
Phone *string `json:"phone"`
|
|
UserType int16 `json:"type"`
|
|
}
|
|
|
|
func (u MGTAndOPSAccountCreationForm) IntoUser() *model.User {
|
|
return &model.User{
|
|
Username: u.Username,
|
|
Password: "",
|
|
ResetNeeded: false,
|
|
UserType: u.UserType,
|
|
Enabled: true,
|
|
CreatedAt: nil,
|
|
}
|
|
}
|
|
|
|
func (u MGTAndOPSAccountCreationForm) IntoUserDetail() *model.UserDetail {
|
|
return &model.UserDetail{
|
|
Id: "",
|
|
Name: &u.Name,
|
|
Abbr: nil,
|
|
Region: nil,
|
|
Address: nil,
|
|
Contact: u.Contact,
|
|
Phone: u.Phone,
|
|
UnitServiceFee: decimal.Zero,
|
|
ServiceExpiration: types.NewDate(2099, time.December, 31),
|
|
CreatedAt: types.Now(),
|
|
CreatedBy: nil,
|
|
LastModifiedAt: types.Now(),
|
|
LastModifiedBy: nil,
|
|
DeletedAt: nil,
|
|
DeletedBy: nil,
|
|
}
|
|
}
|
|
|
|
type EnterpriseAccountCreationForm struct {
|
|
Username string `json:"username"`
|
|
Name string `json:"name"`
|
|
Region *string `json:"region"`
|
|
Address *string `json:"address"`
|
|
Contact *string `json:"contact"`
|
|
Phone *string `json:"phone"`
|
|
UnitServiceFee string `json:"unitServiceFee"`
|
|
}
|
|
|
|
func (u EnterpriseAccountCreationForm) IntoUser() *model.User {
|
|
return &model.User{
|
|
Username: u.Username,
|
|
Password: "",
|
|
ResetNeeded: false,
|
|
UserType: model.USER_TYPE_ENT,
|
|
Enabled: true,
|
|
CreatedAt: nil,
|
|
}
|
|
}
|
|
|
|
func (u EnterpriseAccountCreationForm) IntoUserDetail() (*model.UserDetail, error) {
|
|
unitServiceFee, err := decimal.NewFromString(u.UnitServiceFee)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &model.UserDetail{
|
|
Name: &u.Name,
|
|
Abbr: nil,
|
|
Region: u.Region,
|
|
Address: u.Address,
|
|
Contact: u.Contact,
|
|
Phone: u.Phone,
|
|
UnitServiceFee: unitServiceFee,
|
|
ServiceExpiration: types.NewDate(2000, time.January, 1),
|
|
CreatedAt: types.Now(),
|
|
CreatedBy: nil,
|
|
LastModifiedAt: types.Now(),
|
|
LastModifiedBy: nil,
|
|
DeletedAt: nil,
|
|
DeletedBy: nil,
|
|
}, nil
|
|
}
|
|
|
|
type UserDetailModificationForm struct {
|
|
Name string `json:"name"`
|
|
Region *string `json:"region"`
|
|
Address *string `json:"address"`
|
|
Contact *string `json:"contact"`
|
|
Phone *string `json:"phone"`
|
|
UnitServiceFee *string `json:"unitServiceFee"`
|
|
}
|
|
|
|
func (u UserDetailModificationForm) IntoModificationModel() (*model.UserModificationForm, error) {
|
|
unitServiceFee, err := decimal.NewFromString(*u.UnitServiceFee)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &model.UserModificationForm{
|
|
Name: u.Name,
|
|
Region: u.Region,
|
|
Address: u.Address,
|
|
Contact: u.Contact,
|
|
Phone: u.Phone,
|
|
UnitServiceFee: &unitServiceFee,
|
|
}, nil
|
|
}
|
|
|
|
type UserStateChangeForm struct {
|
|
Uid string `json:"uid"`
|
|
Enabled bool `json:"enabled"`
|
|
}
|
|
|
|
type RepasswordForm struct {
|
|
VerifyCode string `json:"verifyCode"`
|
|
Username string `json:"uname"`
|
|
NewPassword string `json:"newPass"`
|
|
}
|