refactor-location #134

Closed
trunglam wants to merge 270 commits from refactor-location into master
10 changed files with 51 additions and 80 deletions
Showing only changes of commit 33bc508f1f - Show all commits

View File

@ -17,15 +17,15 @@ func GetBank() Bank {
return Bank{}
}
func (s Bank) GetBankById(bankID string) (*model.BankBrief, error) {
msg, err := natsio.GetServer().Request(subject.Bank.GetBankById, toBytes(bankID))
func (s Bank) GetBankAndBranchByBankIDs(p model.GetBankAndBranchesRequest) ([]*model.ResponseBankAndBranches, error) {
msg, err := natsio.GetServer().Request(subject.Bank.GetBankAndBranchesByBankIDs, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.BankBrief `json:"data"`
Error string `json:"error"`
Data []*model.ResponseBankAndBranches `json:"data"`
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
@ -38,7 +38,7 @@ func (s Bank) GetBankById(bankID string) (*model.BankBrief, error) {
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))
if err != nil {
return false

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
}

View File

@ -119,7 +119,7 @@ func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWareh
// GetWarehouseFreeship ...
func (s Supplier) GetWarehouseFreeship() (*model.ResponseListWarehouseIDByBusinessType, error) {
msg, err := natsio.GetServer().Request(subject.Supplier.GetListWarehouseFreeship, toBytes(bson.M{}))
msg, err := natsio.GetServer().Request(subject.Selly.GetListWarehouseFreeship, toBytes(bson.M{}))
if err != nil {
return nil, err
}

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"`
}

10
model/bank_request.go Normal file
View File

@ -0,0 +1,10 @@
package model
type CheckBankAndBranchByIDRequest struct {
BankID string `json:"bankId"`
BranchID string `json:"branchId"`
}
type GetBankAndBranchesRequest struct {
BankIDs []string `json:"bankIds"`
}

View File

@ -1,21 +1,40 @@
package model
import "time"
// MultiLang ...
type MultiLang struct {
En string `json:"en"`
Vi string `json:"vi"`
}
// BankBranchBrief ...
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 ...
type BankBrief struct {
ID string `json:"_id"`
Name MultiLang `json:"name"`
ShortName string `json:"shortName"`
Active bool `json:"active"`
BenBankName string `json:"benBankName"`
BankCode int `json:"bankCode"`
IsBranchRequired bool `json:"isBranchRequired"`
SearchString string `json:"searchString"`
BeneficiaryForVietinbank string `json:"beneficiaryForVietinbank"`
CreatedBy string `json:"createdBy,omitempty"`
ID string `json:"_id"`
Name MultiLang `json:"name"`
ShortName string `json:"shortName"`
Active bool `json:"active"`
BenBankName string `json:"benBankName"`
BankCode int `json:"bankCode"`
IsBranchRequired bool `json:"isBranchRequired"`
BeneficiaryForVietinbank string `json:"beneficiaryForVietinbank"`
CreatedBy string `json:"createdBy,omitempty"`
CreatedAt time.Time `json:"createdAt"`
BranchTotal int64 `json:"branchTotal"`
Logo interface{} `json:"logo"`
}
type ResponseBankAndBranches struct {
Bank BankBrief `json:"bank"`
Branches []BranchBrief `json:"branches"`
}

View File

@ -7,11 +7,9 @@ func getBankValue(val string) string {
}
var Bank = struct {
GetBankById string
GetBankBranchById string
CheckBankAndBranchByID string
GetBankAndBranchesByBankIDs string
CheckBankAndBranchByID string
}{
GetBankById: getBankValue("get_bank_by_id"),
GetBankBranchById: getBankValue("get_bank_branch_by_id"),
CheckBankAndBranchByID: getBankValue("check_bank_and_brach_by_id"),
GetBankAndBranchesByBankIDs: getBankValue("get_bank_and_branches_by_bank_ids"),
CheckBankAndBranchByID: getBankValue("check_bank_and_branch_by_id"),
}

View File

@ -8,6 +8,8 @@ func getSellyValue(val string) string {
var Selly = struct {
GetFreeshipsBySupplierIds string
GetListWarehouseFreeship string
}{
GetFreeshipsBySupplierIds: getSellyValue("get_freeships_by_supplier_ids"),
GetListWarehouseFreeship: getSupplierValue("get_list_warehouse_freeship"),
}

View File

@ -10,10 +10,8 @@ var Supplier = struct {
GetListSupplierInfo string
GetSupplierContractBySupplierID string
FindAll string
GetListWarehouseFreeship string
}{
GetListSupplierInfo: getSupplierValue("get_list_supplier_info"),
GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"),
FindAll: getSupplierValue("find_all"),
GetListWarehouseFreeship: getSupplierValue("get_list_warehouse_freeship"),
}