Develop #22

Merged
luuvansinh merged 56 commits from develop into master 2022-09-13 02:28:19 +00:00
4 changed files with 47 additions and 0 deletions
Showing only changes of commit 9295a8e13f - Show all commits

View File

@ -58,3 +58,24 @@ func (s Supplier) GetSupplierContractBySupplierID(p model.GetSupplierContractReq
return r.Data, nil
}
func (s Supplier) FindAll(supplierID model.SupplierRequestPayload) (*model.SupplierAll, error) {
msg, err := natsio.GetServer().Request(subject.Supplier.FindAll, toBytes(supplierID))
if err != nil {
return nil, err
}
var r struct {
Data *model.SupplierAll `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

@ -12,3 +12,13 @@ type GetSupplierRequest struct {
type GetSupplierContractRequest struct {
SupplierID primitive.ObjectID `json:"supplierID"`
}
// SupplierRequestPayload ...
type SupplierRequestPayload struct {
Limit int
Page int
Keyword string
Status string
PIC string
ContractStatus string
}

View File

@ -13,3 +13,17 @@ type ResponseSupplierContract struct {
Name string `json:"name"`
Status string `json:"status"`
}
// SupplierBrief ...
type SupplierBrief struct {
ID string `json:"_id"`
Name string `json:"name"`
Status string `json:"status"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
type SupplierAll struct {
Suppliers []SupplierBrief `json:"suppliers"`
Total int64 `json:"total"`
}

View File

@ -9,7 +9,9 @@ func getSupplierValue(val string) string {
var Supplier = struct {
GetListSupplierInfo string
GetSupplierContractBySupplierID string
FindAll string
}{
GetListSupplierInfo: getSupplierValue("get_list_supplier_info"),
GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"),
FindAll: getSupplierValue("find_all"),
}