added province name
This commit is contained in:
1 parent
68ead82827
commit
a44c10d445
2 files changed
+17
-13
No files matched your search
@@ -36,10 +36,11 @@ LEFT JOIN loan_order_required_docs d ON d.id = lo.loan_order_required_doc_id`
|
|||||||
|
|
||||||
const loanOrderListFromClause = ` FROM loan_orders lo
|
const loanOrderListFromClause = ` FROM loan_orders lo
|
||||||
LEFT JOIN loan_types lt ON lt.id = lo.loan_type
|
LEFT JOIN loan_types lt ON lt.id = lo.loan_type
|
||||||
LEFT JOIN branches b ON b.id = lo.branch_id`
|
LEFT JOIN branches b ON b.id = lo.branch_id
|
||||||
|
LEFT JOIN provinces bp ON bp.id = b.province_id`
|
||||||
|
|
||||||
const loanOrderListColumns = `lo.id, lo.loan_type, lt.name, lo.created_at, lo.region,
|
const loanOrderListColumns = `lo.id, lo.loan_type, lt.name, lo.created_at, lo.region,
|
||||||
lo.branch_id, b.name, lo.customer_name, lo.customer_surname, lo.phone, lo.status`
|
lo.branch_id, b.name, bp.name, lo.customer_name, lo.customer_surname, lo.phone, lo.status`
|
||||||
|
|
||||||
// loanOrderWritableColumns lists every loan_orders column except id, created_at and
|
// loanOrderWritableColumns lists every loan_orders column except id, created_at and
|
||||||
// updated_at, in the exact order CreateLoanOrderDTO/UpdateLoanOrderDTO fields are read.
|
// updated_at, in the exact order CreateLoanOrderDTO/UpdateLoanOrderDTO fields are read.
|
||||||
@@ -284,11 +285,11 @@ func (r *repository) Delete(ctx context.Context, id int64) error {
|
|||||||
func scanLoanOrderListItem(row genericrepo.Scanner) (loanorders.LoanOrderListItemDTO, error) {
|
func scanLoanOrderListItem(row genericrepo.Scanner) (loanorders.LoanOrderListItemDTO, error) {
|
||||||
var item loanorders.LoanOrderListItemDTO
|
var item loanorders.LoanOrderListItemDTO
|
||||||
var loanTypeId, branchId int64
|
var loanTypeId, branchId int64
|
||||||
var loanTypeNameJSON, branchNameJSON []byte
|
var loanTypeNameJSON, branchNameJSON, provinceNameJSON []byte
|
||||||
|
|
||||||
err := row.Scan(
|
err := row.Scan(
|
||||||
&item.Id, &loanTypeId, &loanTypeNameJSON, &item.CreatedAt, &item.Region,
|
&item.Id, &loanTypeId, &loanTypeNameJSON, &item.CreatedAt, &item.Region,
|
||||||
&branchId, &branchNameJSON, &item.CustomerName, &item.CustomerSurname, &item.Phone, &item.Status,
|
&branchId, &branchNameJSON, &provinceNameJSON, &item.CustomerName, &item.CustomerSurname, &item.Phone, &item.Status,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return loanorders.LoanOrderListItemDTO{}, err
|
return loanorders.LoanOrderListItemDTO{}, err
|
||||||
@@ -297,6 +298,7 @@ func scanLoanOrderListItem(row genericrepo.Scanner) (loanorders.LoanOrderListIte
|
|||||||
var loanTypeName, branchName shared.LocalizedText
|
var loanTypeName, branchName shared.LocalizedText
|
||||||
_ = shared.UnmarshalLocalized(loanTypeNameJSON, &loanTypeName)
|
_ = shared.UnmarshalLocalized(loanTypeNameJSON, &loanTypeName)
|
||||||
_ = shared.UnmarshalLocalized(branchNameJSON, &branchName)
|
_ = shared.UnmarshalLocalized(branchNameJSON, &branchName)
|
||||||
|
_ = shared.UnmarshalLocalized(provinceNameJSON, &item.ProvinceName)
|
||||||
|
|
||||||
if loanTypeId != 0 {
|
if loanTypeId != 0 {
|
||||||
item.LoanType = &shared.NamedInfo{Id: loanTypeId, Name: loanTypeName}
|
item.LoanType = &shared.NamedInfo{Id: loanTypeId, Name: loanTypeName}
|
||||||
|
|||||||
@@ -236,15 +236,17 @@ type ListFilter struct {
|
|||||||
// LoanOrderListItemDTO is the list row; passport, work, card and guarantor
|
// LoanOrderListItemDTO is the list row; passport, work, card and guarantor
|
||||||
// details come from GET /loan-orders/:id.
|
// details come from GET /loan-orders/:id.
|
||||||
type LoanOrderListItemDTO struct {
|
type LoanOrderListItemDTO struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
LoanType *shared.NamedInfo `json:"loanType,omitempty"`
|
LoanType *shared.NamedInfo `json:"loanType,omitempty"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
Region string `json:"region"`
|
Region string `json:"region"`
|
||||||
Branch *shared.NamedInfo `json:"branch,omitempty"`
|
Branch *shared.NamedInfo `json:"branch,omitempty"`
|
||||||
CustomerName string `json:"customerName"`
|
// ProvinceName is the branch's province (etrap).
|
||||||
CustomerSurname string `json:"customerSurname"`
|
ProvinceName shared.LocalizedText `json:"provinceName"`
|
||||||
Phone string `json:"phone"`
|
CustomerName string `json:"customerName"`
|
||||||
Status *string `json:"status"`
|
CustomerSurname string `json:"customerSurname"`
|
||||||
|
Phone string `json:"phone"`
|
||||||
|
Status *string `json:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListLoanOrderDTO struct {
|
type ListLoanOrderDTO struct {
|
||||||
|
|||||||
Reference in new issue
Block a user