fixconflict

This commit is contained in:
anbuiselly 2023-01-17 14:17:52 +07:00
commit d94c6c8430
59 changed files with 1622 additions and 258 deletions

View File

@ -1 +1 @@
# natsio # natsio module

37
client/auth_sms.go Normal file
View File

@ -0,0 +1,37 @@
package client
import (
"encoding/json"
"errors"
"git.selly.red/Selly-Modules/natsio"
"git.selly.red/Selly-Modules/natsio/model"
"git.selly.red/Selly-Modules/natsio/subject"
)
// AuthSMS ...
type AuthSMS struct{}
// GetAuthSMS ...
func GetAuthSMS() AuthSMS {
return AuthSMS{}
}
func (s AuthSMS) CheckPermission(p model.CheckPermissionRequest) error {
msg, err := natsio.GetServer().Request(subject.AuthSMS.CheckPermission, toBytes(p))
if err != nil {
return err
}
var r struct {
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return err
}
if r.Error != "" {
return errors.New(r.Error)
}
return nil
}

View File

@ -17,14 +17,15 @@ func GetBank() Bank {
return Bank{} return Bank{}
} }
func (s Bank) GetBankById(bankID string) (*model.BankBrief, error) { // GetBankInfo ...
msg, err := natsio.GetServer().Request(subject.Bank.GetBankById, toBytes(bankID)) func (s Bank) GetBankInfo(p []model.GetBankInfoRequest) ([]*model.ResponseBankInfo, error) {
msg, err := natsio.GetServer().Request(subject.Bank.GetBankInfo, toBytes(p))
if err != nil { if err != nil {
return nil, err return nil, err
} }
var r struct { var r struct {
Data *model.BankBrief `json:"data"` Data []*model.ResponseBankInfo `json:"data"`
Error string `json:"error"` Error string `json:"error"`
} }
@ -38,18 +39,40 @@ func (s Bank) GetBankById(bankID string) (*model.BankBrief, error) {
return r.Data, nil return r.Data, nil
} }
func (s Bank) CheckBankAndBranchByID(p model.BankBranchRequest) bool { func (s Bank) CheckBankAndBranchByID(p model.CheckBankAndBranchByIDRequest) bool {
msg, err := natsio.GetServer().Request(subject.Bank.CheckBankAndBranchByID, toBytes(p)) msg, err := natsio.GetServer().Request(subject.Bank.CheckBankAndBranchByID, toBytes(p))
if err != nil { if err != nil {
return false return false
} }
var r struct { var r struct {
Error string `json:"error"` Data bool `json:"data"`
} }
if err = json.Unmarshal(msg.Data, &r); err != nil { if err = json.Unmarshal(msg.Data, &r); err != nil {
return false return false
} }
return r.Error == "" return r.Data
}
// GetBankAndBranchDetail ...
func (s Bank) GetBankAndBranchDetail(p model.GetBankInfoRequest) (*model.ResponseBankInfo, error) {
msg, err := natsio.GetServer().Request(subject.Bank.GetBankInfoDetail, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.ResponseBankInfo `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
} }

View File

@ -1,39 +0,0 @@
package client
import (
"encoding/json"
"errors"
"git.selly.red/Selly-Modules/natsio"
"git.selly.red/Selly-Modules/natsio/model"
"git.selly.red/Selly-Modules/natsio/subject"
)
// BankBranch ...
type BankBranch struct{}
// GetBankBranch ...
func GetBankBranch() BankBranch {
return BankBranch{}
}
func (s BankBranch) GetBankBranchById(bankBranchID string) (*model.BankBranchBrief, error) {
msg, err := natsio.GetServer().Request(subject.Bank.GetBankBranchById, toBytes(bankBranchID))
if err != nil {
return nil, err
}
var r struct {
Data *model.BankBranchBrief `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
}

30
client/email.go Normal file
View File

@ -0,0 +1,30 @@
package client
// Email ...
type Email struct{}
// GetEmail ...
func GetEmail() Email {
return Email{}
}
// func (s Email) Send(p model.GetEmailRequest) ([]*model.ResponseEmailInfo, error) {
// msg, err := natsio.GetServer().Request(subject.Email.GetListEmailInfo, toBytes(p))
// if err != nil {
// return nil, err
// }
//
// var r struct {
// Data []*model.ResponseEmailInfo `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
// }

View File

@ -19,7 +19,7 @@ func GetLocation() Location {
// GetLocationByCode ... // GetLocationByCode ...
func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*model.ResponseLocationAddress, error) { func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*model.ResponseLocationAddress, error) {
msg, err := natsio.GetServer().Request(subject.Location.GetLocationByCode, toBytes(payload)) msg, err := natsio.GetServer().Request(subject.Location.GetLocationByCodeNew, toBytes(payload))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -28,7 +28,7 @@ func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*mode
Data *model.ResponseLocationAddress `json:"data"` Data *model.ResponseLocationAddress `json:"data"`
Error string `json:"error"` Error string `json:"error"`
} }
if err := json.Unmarshal(msg.Data, &r); err != nil { if err = json.Unmarshal(msg.Data, &r); err != nil {
return nil, err return nil, err
} }
@ -38,19 +38,19 @@ func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*mode
return r.Data, nil return r.Data, nil
} }
// GetProvincesByCodes ... ... // GetProvincesByCodes ...
func (l Location) GetProvincesByCodes(p model.ProvinceRequestPayload) (*model.LocationProvinceResponse, error) { func (l Location) GetProvincesByCodes(p model.ProvinceRequestPayload) (*model.LocationProvinceResponse, error) {
msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCodes, toBytes(p)) msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCodesNew, toBytes(p))
if err != nil { if err != nil {
return nil, err return nil, err
} }
var r struct { var r struct {
Data *model.LocationProvinceResponse `json:"data"'` Data *model.LocationProvinceResponse `json:"data"`
Error string `json:"error"` Error string `json:"error"`
} }
if err := json.Unmarshal(msg.Data, &r); err != nil { if err = json.Unmarshal(msg.Data, &r); err != nil {
return nil, err return nil, err
} }
@ -62,7 +62,7 @@ func (l Location) GetProvincesByCodes(p model.ProvinceRequestPayload) (*model.Lo
// GetDistrictsByCodes ... // GetDistrictsByCodes ...
func (l Location) GetDistrictsByCodes(p model.DistrictRequestPayload) (*model.LocationDistrictResponse, error) { func (l Location) GetDistrictsByCodes(p model.DistrictRequestPayload) (*model.LocationDistrictResponse, error) {
msg, err := natsio.GetServer().Request(subject.Location.GetDistrictsByCodes, toBytes(p)) msg, err := natsio.GetServer().Request(subject.Location.GetDistrictsByCodesNew, toBytes(p))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -71,7 +71,7 @@ func (l Location) GetDistrictsByCodes(p model.DistrictRequestPayload) (*model.Lo
Error string `json:"error"` Error string `json:"error"`
} }
if err := json.Unmarshal(msg.Data, &r); err != nil { if err = json.Unmarshal(msg.Data, &r); err != nil {
return nil, err return nil, err
} }
@ -84,7 +84,7 @@ func (l Location) GetDistrictsByCodes(p model.DistrictRequestPayload) (*model.Lo
// GetWardsByCodes ... // GetWardsByCodes ...
func (l Location) GetWardsByCodes(p model.WardRequestPayload) (*model.LocationWardResponse, error) { func (l Location) GetWardsByCodes(p model.WardRequestPayload) (*model.LocationWardResponse, error) {
msg, err := natsio.GetServer().Request(subject.Location.GetWardsByCodes, toBytes(p)) msg, err := natsio.GetServer().Request(subject.Location.GetWardsByCodesNew, toBytes(p))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -94,7 +94,7 @@ func (l Location) GetWardsByCodes(p model.WardRequestPayload) (*model.LocationWa
Error string `json:"error"` Error string `json:"error"`
} }
if err := json.Unmarshal(msg.Data, &r); err != nil { if err = json.Unmarshal(msg.Data, &r); err != nil {
return nil, err return nil, err
} }
@ -104,3 +104,211 @@ func (l Location) GetWardsByCodes(p model.WardRequestPayload) (*model.LocationWa
return r.Data, nil return r.Data, nil
} }
// GetProvinceByCondition ...
func (l Location) GetProvinceByCondition(p model.RequestCondition) (*model.LocationProvinceDetailResponse, error) {
msg, err := natsio.GetServer().Request(subject.Location.GetProvinceByCondition, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.LocationProvinceDetailResponse `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
}
// GetProvincesByCondition ...
func (l Location) GetProvincesByCondition(p model.RequestCondition) ([]*model.LocationProvinceDetailResponse, error) {
msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCondition, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data []*model.LocationProvinceDetailResponse `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
}
// GetDistrictByCondition ...
func (l Location) GetDistrictByCondition(p model.RequestCondition) (*model.LocationDistrictDetailResponse, error) {
msg, err := natsio.GetServer().Request(subject.Location.GetDistrictByCondition, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.LocationDistrictDetailResponse `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
}
// GetDistrictsByCondition ...
func (l Location) GetDistrictsByCondition(p model.RequestCondition) ([]*model.LocationDistrictDetailResponse, error) {
msg, err := natsio.GetServer().Request(subject.Location.GetDistrictsByCondition, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data []*model.LocationDistrictDetailResponse `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
}
// GetWardByCondition ...
func (l Location) GetWardByCondition(p model.RequestCondition) (*model.LocationWardDetailResponse, error) {
msg, err := natsio.GetServer().Request(subject.Location.GetWardByCondition, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.LocationWardDetailResponse `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
}
// GetWardsByCondition ...
func (l Location) GetWardsByCondition(p model.RequestCondition) ([]*model.LocationWardDetailResponse, error) {
msg, err := natsio.GetServer().Request(subject.Location.GetWardsByCondition, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data []*model.LocationWardDetailResponse `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
}
// CountProvinceByCondition ...
func (l Location) CountProvinceByCondition(p model.RequestCondition) (int64, error) {
msg, err := natsio.GetServer().Request(subject.Location.CountProvinceByCondition, toBytes(p))
if err != nil {
return 0, err
}
var r struct {
Data int64 `json:"data"`
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return 0, err
}
if r.Error != "" {
return 0, errors.New(r.Error)
}
return r.Data, nil
}
// CountDistrictByCondition ...
func (l Location) CountDistrictByCondition(p model.RequestCondition) (int64, error) {
msg, err := natsio.GetServer().Request(subject.Location.CountDistrictByCondition, toBytes(p))
if err != nil {
return 0, err
}
var r struct {
Data int64 `json:"data"`
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return 0, err
}
if r.Error != "" {
return 0, errors.New(r.Error)
}
return r.Data, nil
}
// CountWardByCondition ...
func (l Location) CountWardByCondition(p model.RequestCondition) (int64, error) {
msg, err := natsio.GetServer().Request(subject.Location.CountWardByCondition, toBytes(p))
if err != nil {
return 0, err
}
var r struct {
Data int64 `json:"data"`
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return 0, err
}
if r.Error != "" {
return 0, errors.New(r.Error)
}
return r.Data, nil
}
// DistinctWithField ...
func (l Location) DistinctWithField(p model.ProvinceDistinctWithField) ([]interface{}, error) {
msg, err := natsio.GetServer().Request(subject.Location.ProvinceDistinctWithField, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data []interface{} `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
}

31
client/notification.go Normal file
View File

@ -0,0 +1,31 @@
package client
import (
"encoding/json"
"errors"
"git.selly.red/Selly-Modules/natsio"
"git.selly.red/Selly-Modules/natsio/model"
"git.selly.red/Selly-Modules/natsio/subject"
)
func GetNotification() Notification {
return Notification{}
}
type Notification struct{}
func (n Notification) SupplierChangeBalanceRequestApproved(p model.NotificationSupplierChangeBalanceRequestApprovedReq) error {
msg, err := natsio.GetServer().Request(subject.Notification.SupplierChangeBalanceRequestApproved, toBytes(p))
if err != nil {
return err
}
var r model.CommonResponseData
if err = json.Unmarshal(msg.Data, &r); err != nil {
return err
}
if r.Error != "" {
return errors.New(r.Error)
}
return nil
}

View File

@ -119,3 +119,24 @@ func (o Order) GetSupplierOrders(p model.OrderSupplierQuery) (*model.SupplierOrd
} }
return &r.Data, nil return &r.Data, nil
} }
// GetSupplierCash ...
func (o Order) GetSupplierCash(p model.OrderSupplierCashReq) (*model.OrderSupplierCashRes, error) {
msg, err := natsio.GetServer().Request(subject.Order.GetSupplierCash, toBytes(p))
if err != nil {
return nil, err
}
var (
r struct {
Data model.OrderSupplierCashRes `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
}

52
client/product.go Normal file
View File

@ -0,0 +1,52 @@
package client
import (
"encoding/json"
"errors"
"git.selly.red/Selly-Modules/natsio"
"git.selly.red/Selly-Modules/natsio/model"
"git.selly.red/Selly-Modules/natsio/subject"
)
// Product ...
type Product struct{}
// GetProduct ...
func GetProduct() Product {
return Product{}
}
func (c Product) ApplyRequest(p model.ProductApplyRequestPayload) error {
msg, err := natsio.GetServer().Request(subject.Product.ApplyRequest, toBytes(p))
if err != nil {
return err
}
var r struct {
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return err
}
if r.Error != "" {
return errors.New(r.Error)
}
return nil
}
func (c Product) ProcessApplyRequest(p model.ProductApplyRequestPayload) error {
msg, err := natsio.GetServer().Request(subject.Product.ProcessApplyRequest, toBytes(p))
if err != nil {
return err
}
var r struct {
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return err
}
if r.Error != "" {
return errors.New(r.Error)
}
return nil
}

35
client/queue.go Normal file
View File

@ -0,0 +1,35 @@
package client
import (
"encoding/json"
"errors"
"git.selly.red/Selly-Modules/natsio"
"git.selly.red/Selly-Modules/natsio/model"
"git.selly.red/Selly-Modules/natsio/subject"
)
// Queue ...
type Queue struct{}
// GetQueue ...
func GetQueue() Queue {
return Queue{}
}
func (c Queue) ScheduleTask(p model.QueueScheduleTaskRequest) error {
msg, err := natsio.GetServer().Request(subject.Queue.ScheduleTask, toBytes(p))
if err != nil {
return err
}
var r struct {
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return err
}
if r.Error != "" {
return errors.New(r.Error)
}
return nil
}

View File

@ -3,6 +3,7 @@ package client
import ( import (
"encoding/json" "encoding/json"
"errors" "errors"
"go.mongodb.org/mongo-driver/bson"
"git.selly.red/Selly-Modules/natsio" "git.selly.red/Selly-Modules/natsio"
"git.selly.red/Selly-Modules/natsio/model" "git.selly.red/Selly-Modules/natsio/model"
@ -165,9 +166,9 @@ func (s Supplier) Count(req model.SupplierCountReq) (*model.SupplierCountRes, er
return r.Data, nil return r.Data, nil
} }
// CreateWarehouseIntoServiceSupplier ... // SyncWarehouseIntoServiceSupplier ...
func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehousePayload) error { func (s Supplier) SyncWarehouseIntoServiceSupplier(p model.SyncSupplierWarehousePayload) error {
msg, err := natsio.GetServer().Request(subject.Warehouse.CreateWarehouseIntoServiceSupplier, toBytes(p)) msg, err := natsio.GetServer().Request(subject.Warehouse.SyncWarehouseIntoServiceSupplier, toBytes(p))
if err != nil { if err != nil {
return err return err
} }
@ -183,9 +184,104 @@ func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWareh
return nil return nil
} }
// UpdateWarehouseIntoServiceSupplier ... // GetListWarehouseFreeShip ...
func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWarehousePayload) error { func (s Supplier) GetListWarehouseFreeShip() (*model.SupplierListWarehouseFreeShipResponse, error) {
msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateWarehouseIntoServiceSupplier, toBytes(p)) msg, err := natsio.GetServer().Request(subject.Supplier.GetListWarehouseFreeShip, toBytes(bson.M{}))
if err != nil {
return nil, err
}
var r struct {
Data *model.SupplierListWarehouseFreeShipResponse `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
}
// GetFreeShipInfo ...
func (s Supplier) GetFreeShipInfo(p model.SupplierFreeShipInfoRequestPayload) ([]*model.SupplierFreeShipInfoResponse, error) {
msg, err := natsio.GetServer().Request(subject.Supplier.GetFreeShipInfo, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data []*model.SupplierFreeShipInfoResponse `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
}
// CreateCashflow ...
func (s Supplier) CreateCashflow(p model.SupplierCashflowCreatePayload) (*model.SupplierCashflowCreateResponse, error) {
msg, err := natsio.GetServer().Request(subject.Supplier.CreateCashflow, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Error string `json:"error"`
Data *model.SupplierCashflowCreateResponse `json:"data"`
}
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 Supplier) UpdateBalance(p model.SupplierUpdateBalanceReq) (*model.SupplierUpdateBalanceRes, error) {
msg, err := natsio.GetServer().Request(subject.Supplier.UpdateBalance, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Error string `json:"error"`
Data *model.SupplierUpdateBalanceRes `json:"data"`
}
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 Supplier) GetCurrentBalance(p model.SupplierGetCurrentBalanceReq) (*model.SupplierGetCurrentBalanceRes, error) {
msg, err := natsio.GetServer().Request(subject.Supplier.GetCurrentBalance, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Error string `json:"error"`
Data *model.SupplierGetCurrentBalanceRes `json:"data"`
}
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 Supplier) DeleteCashflow(p model.SupplierDeleteCashflowReq) error {
msg, err := natsio.GetServer().Request(subject.Supplier.DeleteCashflow, toBytes(p))
if err != nil { if err != nil {
return err return err
} }

View File

@ -0,0 +1,79 @@
package client
import (
"encoding/json"
"errors"
"git.selly.red/Selly-Modules/natsio"
"git.selly.red/Selly-Modules/natsio/model"
"git.selly.red/Selly-Modules/natsio/subject"
)
// SupplierPermission ...
type SupplierPermission struct{}
// GetSupplierPermission ...
func GetSupplierPermission() SupplierPermission {
return SupplierPermission{}
}
func (s SupplierPermission) GetListPermission(p model.GetListPermissionRequest) (*model.GetListPermissionResponse, error) {
msg, err := natsio.GetServer().Request(subject.SupplierPermission.GetList, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.GetListPermissionResponse `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 SupplierPermission) CreatePermission(p model.CreatePermissionRequest) (*model.CreatePermissionResponse, error) {
msg, err := natsio.GetServer().Request(subject.SupplierPermission.Create, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.CreatePermissionResponse `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 SupplierPermission) UpdatePermission(p model.UpdatePermissionRequest) error {
msg, err := natsio.GetServer().Request(subject.SupplierPermission.Update, toBytes(p))
if err != nil {
return err
}
var r struct {
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return err
}
if r.Error != "" {
return errors.New(r.Error)
}
return nil
}

View File

@ -16,8 +16,28 @@ func GetSupplierRole() SupplierRole {
return SupplierRole{} return SupplierRole{}
} }
func (s SupplierRole) GetListRole(p model.GetListRoleRequest) (*model.GetListRoleResponse, error) {
msg, err := natsio.GetServer().Request(subject.SupplierRole.GetList, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.GetListRoleResponse `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 SupplierRole) CreateRole(p model.CreateRoleRequest) (*model.CreateRoleResponse, error) { func (s SupplierRole) CreateRole(p model.CreateRoleRequest) (*model.CreateRoleResponse, error) {
msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateOwner, toBytes(p)) msg, err := natsio.GetServer().Request(subject.SupplierRole.Create, toBytes(p))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -56,3 +76,24 @@ func (s SupplierRole) UpdateRole(p model.UpdateRoleRequest) error {
return nil return nil
} }
func (s SupplierRole) DetailRole(p model.DetailRoleRequest) (*model.RoleBrief, error) {
msg, err := natsio.GetServer().Request(subject.SupplierRole.Detail, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.RoleBrief `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
}

View File

@ -16,6 +16,89 @@ func GetSupplierUser() SupplierUser {
return SupplierUser{} return SupplierUser{}
} }
func (s SupplierUser) LoginUser(p model.LoginUserRequest) (*model.LoginUserResponse, error) {
msg, err := natsio.GetServer().Request(subject.SupplierUser.LoginUser, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.LoginUserResponse `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) Logout(p model.LogoutRequest) error {
msg, err := natsio.GetServer().Request(subject.SupplierUser.Logout, toBytes(p))
if err != nil {
return err
}
var r struct {
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return err
}
if r.Error != "" {
return errors.New(r.Error)
}
return nil
}
func (s SupplierUser) GetListUser(p model.GetListUserRequest) (*model.GetListUserResponse, error) {
msg, err := natsio.GetServer().Request(subject.SupplierUser.GetListUser, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.GetListUserResponse `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) DetailUser(p model.DetailUserRequest) (*model.SupplierUserBrief, error) {
msg, err := natsio.GetServer().Request(subject.SupplierUser.DetailUser, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.SupplierUserBrief `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) { func (s SupplierUser) CreateSupplierOwnerUsers(p model.CreateOwnerRequest) (*model.CreateOwnerResponse, error) {
msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateOwner, toBytes(p)) msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateOwner, toBytes(p))
if err != nil { if err != nil {
@ -99,7 +182,7 @@ func (s SupplierUser) UpdateSupplierStaffUsers(p model.UpdateStaffRequest) error
} }
func (s SupplierUser) UpdateStatus(p model.UpdateStatusRequest) error { func (s SupplierUser) UpdateStatus(p model.UpdateStatusRequest) error {
msg, err := natsio.GetServer().Request(subject.SupplierUser.UpdateStaff, toBytes(p)) msg, err := natsio.GetServer().Request(subject.SupplierUser.UpdateStatus, toBytes(p))
if err != nil { if err != nil {
return err return err
} }
@ -139,6 +222,26 @@ func (s SupplierUser) ResetPassword(p model.ResetPasswordRequest) (*model.ResetP
return r.Data, nil return r.Data, nil
} }
func (s SupplierUser) ChangePassword(p model.ChangePasswordRequest) error {
msg, err := natsio.GetServer().Request(subject.SupplierUser.UpdateStatus, toBytes(p))
if err != nil {
return err
}
var r struct {
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return err
}
if r.Error != "" {
return errors.New(r.Error)
}
return nil
}
// CheckTokenSupplierUser ... // CheckTokenSupplierUser ...
func (s SupplierUser) CheckTokenSupplierUser(p model.CheckTokenSupplierUserPayload) (*model.ResponseCheckTokenSupplierUser, error) { func (s SupplierUser) CheckTokenSupplierUser(p model.CheckTokenSupplierUserPayload) (*model.ResponseCheckTokenSupplierUser, error) {
msg, err := natsio.GetServer().Request(subject.SupplierUser.CheckTokenSupplierUser, toBytes(p)) msg, err := natsio.GetServer().Request(subject.SupplierUser.CheckTokenSupplierUser, toBytes(p))

39
client/withdraw.go Normal file
View File

@ -0,0 +1,39 @@
package client
import (
"encoding/json"
"errors"
"git.selly.red/Selly-Modules/natsio"
"git.selly.red/Selly-Modules/natsio/model"
"git.selly.red/Selly-Modules/natsio/subject"
)
// Withdraw ...
type Withdraw struct{}
// GetWithdraw ...
func GetWithdraw() Withdraw {
return Withdraw{}
}
// GetSupplierCash ...
func (o Withdraw) GetSupplierCash(p model.WithdrawSupplierCashReq) (*model.WithdrawSupplierCashRes, error) {
msg, err := natsio.GetServer().Request(subject.Withdraw.GetSupplierCash, toBytes(p))
if err != nil {
return nil, err
}
var (
r struct {
Data model.WithdrawSupplierCashRes `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
}

View File

@ -0,0 +1,7 @@
package model
type CheckPermissionRequest struct {
Value []string `json:"value"`
ID string `json:"_id"`
DeviceID string `json:"deviceId"`
}

View File

@ -0,0 +1 @@
package model

View File

@ -1,11 +0,0 @@
package model
// BankBranchBrief ...
type BankBranchBrief struct {
ID string `json:"_id"`
City string `json:"city"`
BankCode string `json:"bankCode"`
Bank string `json:"bank"`
Active bool `json:"active"`
Name string `json:"name"`
}

View File

@ -1,6 +0,0 @@
package model
type BankBranchRequest struct {
BankID string `json:"bankId"`
BranchID string `json:"branchId"`
}

11
model/bank_request.go Normal file
View File

@ -0,0 +1,11 @@
package model
type CheckBankAndBranchByIDRequest struct {
BankID string `json:"bankId"`
BranchID string `json:"branchId"`
}
type GetBankInfoRequest struct {
BankID string `json:"bankId"`
BranchID string `json:"branchId"`
}

View File

@ -1,11 +1,23 @@
package model package model
import "time"
// MultiLang ... // MultiLang ...
type MultiLang struct { type MultiLang struct {
En string `json:"en"` En string `json:"en"`
Vi string `json:"vi"` Vi string `json:"vi"`
} }
// BranchBrief ...
type BranchBrief struct {
ID string `json:"_id"`
City string `json:"city"`
BankCode string `json:"bankCode"`
BankID string `json:"bankId"`
Active bool `json:"active"`
Name string `json:"name"`
}
// BankBrief ... // BankBrief ...
type BankBrief struct { type BankBrief struct {
ID string `json:"_id"` ID string `json:"_id"`
@ -15,7 +27,14 @@ type BankBrief struct {
BenBankName string `json:"benBankName"` BenBankName string `json:"benBankName"`
BankCode int `json:"bankCode"` BankCode int `json:"bankCode"`
IsBranchRequired bool `json:"isBranchRequired"` IsBranchRequired bool `json:"isBranchRequired"`
SearchString string `json:"searchString"`
BeneficiaryForVietinbank string `json:"beneficiaryForVietinbank"` BeneficiaryForVietinbank string `json:"beneficiaryForVietinbank"`
CreatedBy string `json:"createdBy,omitempty"` CreatedBy string `json:"createdBy,omitempty"`
CreatedAt time.Time `json:"createdAt"`
BranchTotal int64 `json:"branchTotal"`
Logo interface{} `json:"logo"`
}
type ResponseBankInfo struct {
Bank BankBrief `json:"bank"`
Branch BranchBrief `json:"branch"`
} }

View File

@ -20,3 +20,32 @@ type ActionBy struct {
ID string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
} }
// ClickAction ...
type ClickAction struct {
Type string `json:"type"`
Value string `json:"value"`
}
// RequestCondition ...
type RequestCondition struct {
Code int `json:"code"`
Codes []int `json:"codes"`
DistrictCode int `json:"districtCode"`
ProvinceCode int `json:"provinceCode"`
Slug string `json:"slug"`
OldSlug string `json:"oldSlug"`
Slugs []string `json:"slugs"`
OldSlugs []string `json:"oldSlugs"`
DistrictSlug string `json:"districtSlug"`
ProvinceSlug string `json:"provinceSlug"`
Keyword string `json:"keyword"`
Region string `json:"region"`
Page int64 `json:"page"`
Limit int64 `json:"limit"`
}

View File

@ -1,23 +1,66 @@
package model package model
// LocationRequestPayload ... // LocationRequestPayload ...
type LocationRequestPayload struct { type (
// LocationRequestPayload ...
LocationRequestPayload struct {
Province int `json:"province"` Province int `json:"province"`
District int `json:"district"` District int `json:"district"`
Ward int `json:"ward"` Ward int `json:"ward"`
} }
// ProvinceRequestPayload ... // ProvinceRequestPayload ...
type ProvinceRequestPayload struct { ProvinceRequestPayload struct {
Codes []int `json:"codes"` Codes []int `json:"codes"`
} }
// DistrictRequestPayload ... // ProvinceRequestCondition ...
type DistrictRequestPayload struct { ProvinceRequestCondition struct {
Code int `json:"code"`
Codes []int `json:"codes"` Codes []int `json:"codes"`
} Slug string `json:"slug"`
Slugs []string `json:"slugs"`
Keyword string `json:"keyword"`
Region string `json:"region"`
}
// WardRequestPayload ... // DistrictRequestPayload ...
type WardRequestPayload struct { DistrictRequestPayload struct {
Codes []int `json:"codes"` Codes []int `json:"codes"`
} }
// DistrictRequestCondition ...
DistrictRequestCondition struct {
Code int `json:"code"`
Codes []int `json:"codes"`
ProvinceCode int `json:"provinceCode"`
Slug string `json:"slug"`
ProvinceSlug string `json:"provinceSlug"`
Keyword string `json:"keyword"`
}
// WardRequestPayload ...
WardRequestPayload struct {
Codes []int `json:"codes"`
}
// WardRequestCondition ...
WardRequestCondition struct {
Code int `json:"code"`
Codes []int `json:"codes"`
DistrictCode int `json:"districtCode"`
ProvinceCode int `json:"provinceCode"`
Slug string `json:"slug"`
DistrictSlug string `json:"districtSlug"`
ProvinceSlug string `json:"provinceSlug"`
Keyword string `json:"keyword"`
}
// ProvinceDistinctWithField ...
ProvinceDistinctWithField struct {
Conditions struct {
Region string `json:"region"`
} `json:"conditions"`
Field string `json:"filed"`
}
)

View File

@ -1,43 +1,87 @@
package model package model
type ResponseLocationAddress struct { type (
// ResponseLocationAddress ...
ResponseLocationAddress struct {
Province LocationProvince `json:"province"` Province LocationProvince `json:"province"`
District LocationDistrict `json:"district"` District LocationDistrict `json:"district"`
Ward LocationWard `json:"ward"` Ward LocationWard `json:"ward"`
} }
// LocationProvince ... // LocationProvince ...
type LocationProvince struct { LocationProvince struct {
ID string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Code int `json:"code"` Code int `json:"code"`
} Slug string `json:"slug"`
RegionCode string `json:"regionCode"`
MainRegionCode string `json:"mainRegionCode"`
}
// LocationDistrict ... // LocationDistrict ...
type LocationDistrict struct { LocationDistrict struct {
ID string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Code int `json:"code"` Code int `json:"code"`
} Slug string `json:"slug"`
}
// LocationWard ... // LocationWard ...
type LocationWard struct { LocationWard struct {
ID string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Code int `json:"code"` Code int `json:"code"`
} Slug string `json:"slug"`
}
// LocationProvinceResponse ... // LocationProvinceResponse ...
type LocationProvinceResponse struct { LocationProvinceResponse struct {
Provinces []LocationProvince `json:"provinces"` Provinces []LocationProvince `json:"provinces"`
} }
// LocationDistrictResponse ... // LocationDistrictResponse ...
type LocationDistrictResponse struct { LocationDistrictResponse struct {
Districts []LocationDistrict `json:"districts"` Districts []LocationDistrict `json:"districts"`
} }
// LocationWardResponse ... // LocationWardResponse ...
type LocationWardResponse struct { LocationWardResponse struct {
Wards []LocationWard `json:"wards"` Wards []LocationWard `json:"wards"`
} }
// LocationProvinceDetailResponse ...
LocationProvinceDetailResponse struct {
ID string `json:"_id"`
Name string `json:"name"`
Slug string `json:"slug"`
Code int `json:"code"`
CountryCode string `json:"countryCode"`
RegionCode string `json:"regionCode"`
MainRegionCode string `json:"mainRegionCode"`
TotalDistricts int `json:"totalDistricts"`
TotalWards int `json:"totalWards"`
}
// LocationDistrictDetailResponse ...
LocationDistrictDetailResponse struct {
ID string `json:"_id"`
Name string `json:"name"`
OldSlugs []string `json:"oldSlugs"`
Slug string `json:"slug"`
Code int `json:"code"`
ProvinceCode int `json:"provinceCode"`
Area int `json:"area"`
TotalWards int `json:"totalWards"`
}
// LocationWardDetailResponse ...
LocationWardDetailResponse struct {
ID string `json:"_id"`
Name string `json:"name"`
OldSlugs []string `json:"oldSlugs"`
Slug string `json:"slug"`
Code int `json:"code"`
DistrictCode int `json:"districtCode"`
ProvinceCode int `json:"provinceCode"`
}
)

View File

@ -0,0 +1,7 @@
package model
type NotificationSupplierChangeBalanceRequestApprovedReq struct {
SupplierID string `json:"supplierId"`
Cash float64 `json:"cash"`
Reason string `json:"reason"`
}

View File

@ -0,0 +1 @@
package model

View File

@ -49,3 +49,7 @@ type OrderSupplierQuery struct {
SupplierID string `json:"supplierId"` SupplierID string `json:"supplierId"`
WarehouseIDs []string `json:"warehouseIDs"` WarehouseIDs []string `json:"warehouseIDs"`
} }
type OrderSupplierCashReq struct {
SupplierID string `json:"supplierId"`
}

View File

@ -33,3 +33,9 @@ type SupplierOrderDelivery struct {
Status string `json:"status" enums:"waiting_to_confirm,waiting_to_pick,picking,picked,delay_pickup,pickup_failed,delivering,delay_delivery,delivered,cancelled,delivery_failed,waiting_to_return,returning,delay_return,compensation,returned"` Status string `json:"status" enums:"waiting_to_confirm,waiting_to_pick,picking,picked,delay_pickup,pickup_failed,delivering,delay_delivery,delivered,cancelled,delivery_failed,waiting_to_return,returning,delay_return,compensation,returned"`
TPLCode string `json:"tplCode" enums:"SLY,GHTK,GHN,SSC,SPY,VTP,SE,NTL,BEST"` TPLCode string `json:"tplCode" enums:"SLY,GHTK,GHN,SSC,SPY,VTP,SE,NTL,BEST"`
} }
type OrderSupplierCashRes struct {
PendingCash float64 `json:"pendingCash"`
WaitingForReconcileCash float64 `json:"waitingForReconcileCash"`
ReconciledCash float64 `json:"reconciledCash"`
}

5
model/product_request.go Normal file
View File

@ -0,0 +1,5 @@
package model
type ProductApplyRequestPayload struct {
RequestID string `json:"requestId"`
}

8
model/queue_request.go Normal file
View File

@ -0,0 +1,8 @@
package model
type QueueScheduleTaskRequest struct {
ID string `json:"id"`
NatsSubject string `json:"natsSubject"`
Data string `json:"data"`
StartAt int64 `json:"startAt"` // unix
}

View File

@ -0,0 +1 @@
package model

View File

@ -0,0 +1 @@
package model

View File

@ -0,0 +1,24 @@
package model
type GetListPermissionRequest struct {
Page int `json:"page"`
Limit int `json:"limit"`
Group string `json:"group"`
}
type DetailPermissionRequest struct {
ID string `json:"_id"`
}
type CreatePermissionRequest struct {
Name string `json:"name"`
Code string `json:"code"`
Group string `json:"group"`
}
type UpdatePermissionRequest struct {
ID string `json:"_id"`
Name string `json:"name"`
Code string `json:"code"`
Group string `json:"group"`
}

View File

@ -0,0 +1,26 @@
package model
type GetListPermissionResponse struct {
Permissions []PermissionBrief `json:"permissions"`
Total int64 `json:"total"`
}
type PermissionBrief struct {
ID string `json:"_id"`
Name string `json:"name"`
Code string `json:"code"`
Group string `json:"group"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
type CreatePermissionResponse struct {
ID string `json:"_id"`
}
type PermissionShort struct {
ID string `json:"_id"`
Name string `json:"name"`
Code string `json:"code"`
Group string `json:"group"`
}

View File

@ -28,20 +28,30 @@ type SupplierRequestPayload struct {
ContractStatus string ContractStatus string
} }
type CreateSupplierWarehousePayload struct { // SupplierCashflowCreatePayload ...
type SupplierCashflowCreatePayload struct {
Supplier string `json:"supplier"` Supplier string `json:"supplier"`
Warehouse string `json:"warehouse"` Action string `json:"action"`
ProvinceCode int `json:"provinceCode"` Name string `json:"name"`
DistrictCode int `json:"districtCode"` TargetID string `json:"targetId"`
WardCode int `json:"wardCode"` Value float64 `json:"value"`
ClickAction *ClickAction `json:"clickAction"`
} }
type UpdateSupplierWarehousePayload struct { type SupplierFreeShipInfoRequestPayload struct {
Supplier string `json:"supplier"` SupplierIDs []string `json:"supplierIds"`
Warehouse string `json:"warehouse"` }
ProvinceCode int `json:"provinceCode"`
DistrictCode int `json:"districtCode"` type SupplierUpdateBalanceReq struct {
WardCode int `json:"wardCode"` SupplierID string `json:"supplierId"`
}
type SupplierGetCurrentBalanceReq struct {
SupplierID string `json:"supplierId"`
}
type SupplierDeleteCashflowReq struct {
CashflowID string `json:"cashflowId"`
} }
type SupplierFindAllReq struct { type SupplierFindAllReq struct {

View File

@ -5,6 +5,54 @@ type ResponseSupplierInfo struct {
ID string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
BusinessType string `json:"businessType"` BusinessType string `json:"businessType"`
Statistic SupplierStatistic `json:"statistic"`
Rating float64 `json:"rating"`
Inventories []*SKUCommonInfo `json:"inventories"`
Active bool `json:"active"`
}
// SupplierStatistic ...
type SupplierStatistic struct {
TotalInventory int64 `json:"totalInventory"`
TotalQuantitySale int64 `json:"totalQuantitySale"`
TotalProduct int64 `json:"totalProduct"`
TotalHasOrderSeller int64 `json:"totalHasOrderSeller"`
TotalFollower int64 `json:"totalFollower"`
SalesTotal float64 `json:"salesTotal"`
SalesWeekTotal float64 `json:"salesWeekTotal"`
SalesMonthTotal float64 `json:"salesMonthTotal"`
SalesTwoMonthTotal float64 `json:"salesTwoMonthTotal"`
SalesYearTotal float64 `json:"salesYearTotal"`
SalesSuccess float64 `json:"salesSuccess"`
SalesPending float64 `json:"salesPending"`
SalesCancelled float64 `json:"salesCancelled"`
}
// SKUCommonInfo ...
type SKUCommonInfo struct {
Code int `json:"id,omitempty" bson:"id,omitempty"`
ID string `json:"_id" bson:"_id"`
Name string `json:"name" bson:"name"`
SearchString string `json:"-" bson:"searchString,omitempty"`
Location *LocationInventory `json:"location,omitempty" bson:"location,omitempty"`
MinimumValue float64 `json:"minimumValue,omitempty" bson:"-"`
}
// LocationInventory ...
type LocationInventory struct {
Address string `bson:"address" json:"address"`
Province string `bson:"province" json:"province"`
ProvinceName string `bson:"provinceName,omitempty" json:"provinceName,omitempty"`
District string `bson:"district" json:"district"`
Ward string `bson:"ward" json:"ward"`
FullAddress string `bson:"fullAddress,omitempty" json:"fullAddress,omitempty"`
Location *MongoLocation `bson:"location" json:"location"`
}
// MongoLocation ...
type MongoLocation struct {
Type string `bson:"type"`
Coordinates []float64 `bson:"coordinates"`
} }
// ResponseSupplierContract ... // ResponseSupplierContract ...
@ -30,6 +78,57 @@ type SupplierAll struct {
Total int64 `json:"total"` Total int64 `json:"total"`
} }
type SupplierListWarehouseFreeShipResponse struct {
Warehouses []string `json:"warehouses"`
}
type SupplierCashflowCreateResponse struct {
ID string `json:"id"`
}
type FreeShip struct {
ID string `json:"_id"`
ShortName string `json:"shortName"`
ListMilestoneText []string `json:"milestoneText"`
Order int `json:"-"`
}
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"`
}
type SupplierUpdateBalanceRes struct {
CurrentCash float64 `json:"currentCash"`
TotalPendingCash float64 `json:"totalPendingCash"`
OrderPendingCash float64 `json:"orderPendingCash"`
OrderWaitingForReconcileCash float64 `json:"orderWaitingForReconcileCash"`
OrderReconciledCash float64 `json:"orderReconciledCash"`
WithdrawPendingCash float64 `json:"withdrawPendingCash"`
WithdrawSuccessCash float64 `json:"withdrawSuccessCash"`
WithdrawRejectCash float64 `json:"withdrawRejectCash"`
ChangeBalanceRequestApproved float64 `json:"changeBalanceRequestApproved"`
UpdatedAt string `json:"updatedAt"`
}
type SupplierGetCurrentBalanceRes struct {
CurrentCash float64 `json:"currentCash"`
}
type SyncSupplierWarehousePayload struct {
Supplier string `json:"supplier"`
Warehouse string `json:"warehouse"`
ProvinceCode int `json:"provinceCode"`
DistrictCode int `json:"districtCode"`
WardCode int `json:"wardCode"`
}
type SupplierCountRes struct { type SupplierCountRes struct {
Total int64 `json:"total"` Total int64 `json:"total"`
} }

View File

@ -1,9 +1,22 @@
package model package model
type GetListRoleRequest struct {
Page int `json:"page"`
Limit int `json:"limit"`
Type string `json:"type"`
SupplierID string `json:"supplierId"`
}
type DetailRoleRequest struct {
ID string `json:"_id"`
}
type CreateRoleRequest struct { type CreateRoleRequest struct {
Name string `json:"name"` Name string `json:"name"`
Code string `json:"code"` Code string `json:"code"`
Type string `json:"type"` Type string `json:"type"`
SupplierID string `json:"supplierId"`
Permissions []string `json:"permissions"`
} }
type UpdateRoleRequest struct { type UpdateRoleRequest struct {
@ -11,4 +24,6 @@ type UpdateRoleRequest struct {
Name string `json:"name"` Name string `json:"name"`
Code string `json:"code"` Code string `json:"code"`
Type string `json:"type"` Type string `json:"type"`
SupplierID string `json:"supplierId"`
Permissions []string `json:"permissions"`
} }

View File

@ -1,5 +1,29 @@
package model package model
type GetListRoleResponse struct {
Roles []RoleBrief `json:"roles"`
Total int64 `json:"total"`
}
type RoleBrief struct {
ID string `json:"_id"`
Name string `json:"name"`
Code string `json:"code"`
Type string `json:"type"`
Permissions []PermissionShort `json:"permissions"`
SupplierId string `json:"supplierId"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
type CreateRoleResponse struct { type CreateRoleResponse struct {
ID string `json:"_id"` ID string `json:"_id"`
} }
type RoleShort struct {
ID string `json:"_id"`
Name string `json:"name"`
Code string `json:"code"`
Type string `json:"type"`
SupplierId string `json:"supplierId"`
}

View File

@ -1,12 +1,44 @@
package model package model
type LoginUserRequest struct {
Email string `json:"email"`
Password string `json:"password"`
DeviceID string `json:"deviceId"`
AppVersion string `json:"appVersion"`
UserAgent string `json:"userAgent"`
Model string `json:"model"`
Manufacturer string `json:"manufacturer"`
IP string `json:"ip"`
Language string `json:"language"`
FCMToken string `json:"FCMToken"`
AuthToken string `json:"authToken"`
OsName string `json:"osName"`
OsVersion string `json:"osVersion"`
IsMobile bool `json:"isMobile"`
}
type LogoutRequest struct {
ID string `json:"_id"`
}
type GetListUserRequest struct {
Page int `json:"page"`
Limit int `json:"limit"`
Status string `json:"status"`
Type string `json:"type"`
SupplierID string `json:"supplierId"`
}
type DetailUserRequest struct {
ID string `json:"_id"`
}
type CreateOwnerRequest struct { type CreateOwnerRequest struct {
Name string `json:"name"` Name string `json:"name"`
Phone string `json:"phone"` Phone string `json:"phone"`
Email string `json:"email"` Email string `json:"email"`
SupplierID string `json:"supplierId"` SupplierID string `json:"supplierId"`
RoleID string `json:"roleId"` RoleID string `json:"roleId"`
Password string `json:"password"`
} }
type UpdateOwnerRequest struct { type UpdateOwnerRequest struct {
@ -24,7 +56,6 @@ type CreateStaffRequest struct {
Email string `json:"email"` Email string `json:"email"`
SupplierID string `json:"supplierId"` SupplierID string `json:"supplierId"`
RoleID string `json:"roleId"` RoleID string `json:"roleId"`
Password string `json:"password"`
Warehouses []string `json:"warehouses"` Warehouses []string `json:"warehouses"`
} }
@ -47,6 +78,10 @@ type UpdateStatusRequest struct {
type ResetPasswordRequest struct { type ResetPasswordRequest struct {
ID string `json:"_id"` ID string `json:"_id"`
}
type ChangePasswordRequest struct {
ID string `json:"_id"`
Password string `json:"password"` Password string `json:"password"`
} }

View File

@ -1,5 +1,33 @@
package model package model
// LoginUserResponse ...
type LoginUserResponse struct {
ID string `json:"_id"`
RequireToChangePassword bool `json:"requireToChangePassword"`
SupplierID string `json:"supplierId"`
Name string `json:"name"`
}
type GetListUserResponse struct {
SupplierUsers []SupplierUserBrief `json:"supplierUsers"`
Total int64 `json:"total"`
}
type SupplierUserBrief struct {
ID string `json:"_id"`
Role RoleShort `json:"role"`
SupplierID string `json:"supplierId"`
Name string `json:"name"`
Phone string `json:"phone"`
Email string `json:"email"`
Status string `json:"status"`
Avatar interface{} `json:"avatar"`
Type string `json:"type"`
Warehouses []string `json:"warehouses"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
type CreateOwnerResponse struct { type CreateOwnerResponse struct {
ID string `json:"_id"` ID string `json:"_id"`
} }

View File

@ -101,6 +101,7 @@ type GetWarehousesRequest struct {
Status string `json:"status"` Status string `json:"status"`
Supplier string `json:"supplier"` Supplier string `json:"supplier"`
BusinessType string `json:"businessType"` BusinessType string `json:"businessType"`
IDs []string `json:"ids"`
Page int64 `json:"page"` Page int64 `json:"page"`
Limit int64 `json:"limit"` Limit int64 `json:"limit"`

View File

@ -119,6 +119,7 @@ type CommonLocation struct {
ID string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Code int `json:"code"` Code int `json:"code"`
Slug string `json:"slug"`
} }
// ResponseLatLng ... // ResponseLatLng ...

View File

@ -0,0 +1,5 @@
package model
type WithdrawSupplierCashReq struct {
SupplierID string `json:"supplierId"`
}

View File

@ -0,0 +1,7 @@
package model
type WithdrawSupplierCashRes struct {
PendingCash float64 `json:"pendingCash"`
SuccessCash float64 `json:"successCash"`
RejectCash float64 `json:"rejectCash"`
}

15
subject/auth_sms.go Normal file
View File

@ -0,0 +1,15 @@
package subject
import "fmt"
func getAuthSMSValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.AuthSMS, val)
}
var AuthSMS = struct {
// AuthSMS
CheckPermission string
}{
// Users
CheckPermission: getAuthSMSValue("check_permission"),
}

View File

@ -7,11 +7,11 @@ func getBankValue(val string) string {
} }
var Bank = struct { var Bank = struct {
GetBankById string GetBankInfo string
GetBankBranchById string GetBankInfoDetail string
CheckBankAndBranchByID string CheckBankAndBranchByID string
}{ }{
GetBankById: getBankValue("get_bank_by_id"), GetBankInfo: getBankValue("get_bank_info"),
GetBankBranchById: getBankValue("get_bank_branch_by_id"), GetBankInfoDetail: getBankValue("get_bank_info_detail"),
CheckBankAndBranchByID: getBankValue("check_bank_and_brach_by_id"), CheckBankAndBranchByID: getBankValue("check_bank_and_branch_by_id"),
} }

View File

@ -9,13 +9,20 @@ var prefixes = struct {
Bank string Bank string
Supplier string Supplier string
Seller string Seller string
SupplierUser string AuthSMS string
SupplierRole string Selly string
SupplierPermission string
Withdraw string
Notification string
SocialPost string SocialPost string
Staff string Staff string
Segment string Segment string
SupplierUser string
SupplierRole string
Campaign string Campaign string
Affiliate string Affiliate string
Product string
Queue string
}{ }{
Communication: "communication", Communication: "communication",
Order: "order", Order: "order",
@ -25,11 +32,18 @@ var prefixes = struct {
Supplier: "supplier", Supplier: "supplier",
Bank: "bank", Bank: "bank",
Seller: "seller", Seller: "seller",
AuthSMS: "auth_sms",
Selly: "selly",
SupplierUser: "supplier_user", SupplierUser: "supplier_user",
SupplierRole: "supplier_role", SupplierRole: "supplier_role",
SupplierPermission: "supplier_permission",
Withdraw: "withdraw",
Notification: "notification",
SocialPost: "social_post", SocialPost: "social_post",
Staff: "staff", Staff: "staff",
Segment: "segment", Segment: "segment",
Campaign: "campaign", Campaign: "campaign",
Affiliate: "affiliate", Affiliate: "affiliate",
Product: "product",
Queue: "queue",
} }

View File

@ -8,12 +8,40 @@ func getLocationValue(val string) string {
var Location = struct { var Location = struct {
GetLocationByCode string GetLocationByCode string
GetLocationByCodeNew string
GetProvincesByCodes string GetProvincesByCodes string
GetProvincesByCodesNew string
GetDistrictsByCodes string GetDistrictsByCodes string
GetDistrictsByCodesNew string
GetWardsByCodes string GetWardsByCodes string
GetWardsByCodesNew string
GetProvinceByCondition string
GetProvincesByCondition string
GetDistrictByCondition string
GetDistrictsByCondition string
GetWardByCondition string
GetWardsByCondition string
CountProvinceByCondition string
CountDistrictByCondition string
CountWardByCondition string
ProvinceDistinctWithField string
}{ }{
GetLocationByCode: getLocationValue("get_location_warehouse"), GetLocationByCode: getLocationValue("get_location_warehouse"),
GetLocationByCodeNew: getLocationValue("get_location_warehouse_new"),
GetProvincesByCodes: getLocationValue("get_provinces_by_codes"), GetProvincesByCodes: getLocationValue("get_provinces_by_codes"),
GetProvincesByCodesNew: getLocationValue("get_provinces_by_codes_new"),
GetDistrictsByCodes: getLocationValue("get_districts_by_codes"), GetDistrictsByCodes: getLocationValue("get_districts_by_codes"),
GetDistrictsByCodesNew: getLocationValue("get_districts_by_codes_new"),
GetWardsByCodes: getLocationValue("get_wards_by_codes"), GetWardsByCodes: getLocationValue("get_wards_by_codes"),
GetWardsByCodesNew: getLocationValue("get_wards_by_codes_new"),
GetProvinceByCondition: getLocationValue("get_province_by_condition"),
GetProvincesByCondition: getLocationValue("get_provinces_by_condition"),
GetDistrictByCondition: getLocationValue("get_district_by_condition"),
GetDistrictsByCondition: getLocationValue("get_districts_byCondition"),
GetWardByCondition: getLocationValue("get_ward_by_condition"),
GetWardsByCondition: getLocationValue("get_wards_by_condition"),
CountProvinceByCondition: getLocationValue("count_province_by_condition"),
CountDistrictByCondition: getLocationValue("count_district_by_condition"),
CountWardByCondition: getLocationValue("count_ward_by_condition"),
ProvinceDistinctWithField: getLocationValue("province_distinct_with_field"),
} }

13
subject/notification.go Normal file
View File

@ -0,0 +1,13 @@
package subject
import "fmt"
func getNotificationValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.Notification, val)
}
var Notification = struct {
SupplierChangeBalanceRequestApproved string
}{
SupplierChangeBalanceRequestApproved: getNotificationValue("supplier_change_balance_request_approved"),
}

View File

@ -13,6 +13,7 @@ var Order = struct {
UpdateLogisticInfoFailed string UpdateLogisticInfoFailed string
ORNotUpdateStatus string ORNotUpdateStatus string
GetSupplierOrders string GetSupplierOrders string
GetSupplierCash string
}{ }{
UpdateORStatus: getOrderValue("update_outbound_request_status"), UpdateORStatus: getOrderValue("update_outbound_request_status"),
CancelDelivery: getOrderValue("cancel_delivery"), CancelDelivery: getOrderValue("cancel_delivery"),
@ -20,4 +21,5 @@ var Order = struct {
UpdateLogisticInfoFailed: getOrderValue("update_logistic_info_failed"), UpdateLogisticInfoFailed: getOrderValue("update_logistic_info_failed"),
ORNotUpdateStatus: getOrderValue("outbound_request_not_update_status"), ORNotUpdateStatus: getOrderValue("outbound_request_not_update_status"),
GetSupplierOrders: getOrderValue("get_supplier_orders"), GetSupplierOrders: getOrderValue("get_supplier_orders"),
GetSupplierCash: getOrderValue("get_supplier_cash"),
} }

16
subject/product.go Normal file
View File

@ -0,0 +1,16 @@
package subject
import "fmt"
// getSegmentValue ...
func getProductValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.Product, val)
}
var Product = struct {
ApplyRequest string
ProcessApplyRequest string
}{
ApplyRequest: getProductValue("apply_request"),
ProcessApplyRequest: getProductValue("process_apply_request"),
}

13
subject/queue.go Normal file
View File

@ -0,0 +1,13 @@
package subject
import "fmt"
func getQueueValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.Queue, val)
}
var Queue = struct {
ScheduleTask string
}{
ScheduleTask: getQueueValue("schedule_task"),
}

View File

@ -11,6 +11,12 @@ var Supplier = struct {
GetDetailSupplierInfo string GetDetailSupplierInfo string
GetSupplierContractBySupplierID string GetSupplierContractBySupplierID string
FindAll string FindAll string
GetListWarehouseFreeShip string
CreateCashflow string
DeleteCashflow string
UpdateBalance string
GetCurrentBalance string
GetFreeShipInfo string
FindAllOld string FindAllOld string
Count string Count string
}{ }{
@ -18,6 +24,12 @@ var Supplier = struct {
GetDetailSupplierInfo: getSupplierValue("get_detail_supplier_info"), GetDetailSupplierInfo: getSupplierValue("get_detail_supplier_info"),
GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"),
FindAll: getSupplierValue("find_all"), FindAll: getSupplierValue("find_all"),
GetListWarehouseFreeShip: getSupplierValue("get_list_warehouse_free_ship"),
CreateCashflow: getSupplierValue("create_cashflow"),
DeleteCashflow: getSupplierValue("delete_cashflow"),
UpdateBalance: getSupplierValue("update_balance"),
GetCurrentBalance: getSupplierValue("get_current_balance"),
GetFreeShipInfo: getSupplierValue("get_free_ship_info"),
FindAllOld: getSupplierValue("find_all_old"), FindAllOld: getSupplierValue("find_all_old"),
Count: getSupplierValue("count"), Count: getSupplierValue("count"),
} }

View File

@ -0,0 +1,17 @@
package subject
import "fmt"
func getPermissionValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.SupplierPermission, val)
}
var SupplierPermission = struct {
GetList string
Create string
Update string
}{
GetList: getPermissionValue("get_list"),
Create: getPermissionValue("create"),
Update: getPermissionValue("update"),
}

View File

@ -7,9 +7,15 @@ func getRoleValue(val string) string {
} }
var SupplierRole = struct { var SupplierRole = struct {
GetList string
Detail string
Create string Create string
Update string Update string
GetListBySupplierID string
}{ }{
GetList: getRoleValue("get_list"),
Detail: getRoleValue("detail"),
Create: getRoleValue("create"), Create: getRoleValue("create"),
Update: getRoleValue("update"), Update: getRoleValue("update"),
GetListBySupplierID: getRoleValue("get_list_by_supplierId"),
} }

View File

@ -8,20 +8,30 @@ func getSupplierUserValue(val string) string {
var SupplierUser = struct { var SupplierUser = struct {
// Users // Users
LoginUser string
Logout string
GetListUser string
DetailUser string
CreateOwner string CreateOwner string
UpdateOwner string UpdateOwner string
CreateStaff string CreateStaff string
UpdateStaff string UpdateStaff string
UpdateStatus string UpdateStatus string
ResetPassword string ResetPassword string
ChangePassword string
CheckTokenSupplierUser string CheckTokenSupplierUser string
}{ }{
// Users // Users
LoginUser: getSupplierUserValue("login_user"),
Logout: getSupplierUserValue("logout"),
GetListUser: getSupplierUserValue("get_list_user"),
DetailUser: getSupplierUserValue("detail_user"),
CreateOwner: getSupplierUserValue("create_owner"), CreateOwner: getSupplierUserValue("create_owner"),
UpdateOwner: getSupplierUserValue("update_owner"), UpdateOwner: getSupplierUserValue("update_owner"),
CreateStaff: getSupplierUserValue("create_staff"), CreateStaff: getSupplierUserValue("create_staff"),
UpdateStaff: getSupplierUserValue("update_staff"), UpdateStaff: getSupplierUserValue("update_staff"),
UpdateStatus: getSupplierUserValue("update_status"), UpdateStatus: getSupplierUserValue("update_status"),
ResetPassword: getSupplierUserValue("reset_password"), ResetPassword: getSupplierUserValue("reset_password"),
ChangePassword: getSupplierUserValue("change_password"),
CheckTokenSupplierUser: getSupplierUserValue("check_token_supplier_user"), CheckTokenSupplierUser: getSupplierUserValue("check_token_supplier_user"),
} }

View File

@ -9,6 +9,7 @@ func getWarehouseValue(val string) string {
} }
var Warehouse = struct { var Warehouse = struct {
SyncWarehouseIntoServiceSupplier string
CreateWarehouseIntoServiceSupplier string CreateWarehouseIntoServiceSupplier string
UpdateWarehouseIntoServiceSupplier string UpdateWarehouseIntoServiceSupplier string
CreateOutboundRequest string CreateOutboundRequest string
@ -17,6 +18,7 @@ var Warehouse = struct {
GetConfiguration string GetConfiguration string
SyncORStatus string SyncORStatus string
WebhookTNC string WebhookTNC string
WebhookShiip string
WebhookGlobalCare string WebhookGlobalCare string
WebhookOnPoint string WebhookOnPoint string
FindOne string FindOne string
@ -30,6 +32,7 @@ var Warehouse = struct {
UpdateORDeliveryStatus string UpdateORDeliveryStatus string
UpdateStatusWarehousePendingInactive string UpdateStatusWarehousePendingInactive string
}{ }{
SyncWarehouseIntoServiceSupplier: getWarehouseValue("sync_warehouse_into_service_supplier"),
CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"),
UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"),
AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"), AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"),
@ -40,6 +43,7 @@ var Warehouse = struct {
GetConfiguration: getWarehouseValue("get_configuration"), GetConfiguration: getWarehouseValue("get_configuration"),
SyncORStatus: getWarehouseValue("sync_or_status"), SyncORStatus: getWarehouseValue("sync_or_status"),
WebhookTNC: getWarehouseValue("webhook_tnc"), WebhookTNC: getWarehouseValue("webhook_tnc"),
WebhookShiip: getWarehouseValue("webhook_shiip"),
WebhookGlobalCare: getWarehouseValue("webhook_global_care"), WebhookGlobalCare: getWarehouseValue("webhook_global_care"),
WebhookOnPoint: getWarehouseValue("webhook_on_point"), WebhookOnPoint: getWarehouseValue("webhook_on_point"),
FindOne: getWarehouseValue("find_one"), FindOne: getWarehouseValue("find_one"),
@ -49,5 +53,5 @@ var Warehouse = struct {
UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"),
GetWarehouses: getWarehouseValue("get_warehouses"), GetWarehouses: getWarehouseValue("get_warehouses"),
UpdateORDeliveryStatus: getWarehouseValue("update_or_delivery_status"), UpdateORDeliveryStatus: getWarehouseValue("update_or_delivery_status"),
UpdateStatusWarehousePendingInactive: getWarehouseValue("update_status_warehouse_pending_inactive"), UpdateStatusWarehousePendingInactive: getWarehouseValue("update_pending_active_product_by_warehouse_ids"),
} }

13
subject/withdraw.go Normal file
View File

@ -0,0 +1,13 @@
package subject
import "fmt"
func getWithdrawValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.Withdraw, val)
}
var Withdraw = struct {
GetSupplierCash string
}{
GetSupplierCash: getWithdrawValue("get_supplier_cash"),
}