refactor-location #134

Closed
trunglam wants to merge 270 commits from refactor-location into master
5 changed files with 55 additions and 0 deletions
Showing only changes of commit 645effaa04 - Show all commits

View File

@ -16,6 +16,27 @@ func GetSupplierUser() SupplierUser {
return SupplierUser{}
}
func (s SupplierUser) GetListOwner(p model.GetListOwnerRequest) (*model.GetListOwnerResponse, error) {
msg, err := natsio.GetServer().Request(subject.SupplierUser.GetListOwner, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.GetListOwnerResponse `json:"data"`
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return nil, err
}
if r.Error != "" {
return nil, errors.New(r.Error)
}
return r.Data, nil
}
func (s SupplierUser) CreateSupplierOwnerUsers(p model.CreateOwnerRequest) (*model.CreateOwnerResponse, error) {
msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateOwner, toBytes(p))
if err != nil {

View File

@ -49,3 +49,9 @@ type SupplierFreeShipInfoResponse struct {
SupplierID string `json:"supplierId"`
FreeShips []FreeShip `json:"freeShips"`
}
type SupplierShort struct {
ID string `json:"_id"`
Name string `json:"name"`
Logo interface{} `json:"logo"`
}

View File

@ -1,5 +1,12 @@
package model
type GetListOwnerRequest struct {
Page int `json:"page"`
Limit int `json:"limit"`
Status string `json:"status"`
SupplierID string `json:"supplierId"`
}
type CreateOwnerRequest struct {
Name string `json:"name"`
Phone string `json:"phone"`

View File

@ -1,5 +1,24 @@
package model
type GetListOwnerResponse struct {
SupplierUsers []SupplierUserBrief `json:"supplierUsers"`
Total int64 `json:"total"`
}
type SupplierUserBrief struct {
ID string `json:"_id"`
Role RoleBrief `json:"role"`
Supplier SupplierShort `json:"supplier"`
Name string `json:"name"`
Phone string `json:"phone"`
Email string `json:"email"`
Status string `json:"status"`
Avatar interface{} `json:"avatar"`
Type string `json:"type"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
type CreateOwnerResponse struct {
ID string `json:"_id"`
}

View File

@ -8,6 +8,7 @@ func getSupplierUserValue(val string) string {
var SupplierUser = struct {
// Users
GetListOwner string
CreateOwner string
UpdateOwner string
CreateStaff string
@ -16,6 +17,7 @@ var SupplierUser = struct {
ResetPassword string
}{
// Users
GetListOwner: getSupplierUserValue("get_list_owner"),
CreateOwner: getSupplierUserValue("create_owner"),
UpdateOwner: getSupplierUserValue("update_owner"),
CreateStaff: getSupplierUserValue("create_staff"),