修改后端接口
This commit is contained in:
@@ -35,6 +35,9 @@ const getApplications = async (req, res) => {
|
||||
where.customer_phone = { [Op.like]: `%${searchValue}%` };
|
||||
} else if (searchField === 'customerIdCard') {
|
||||
where.customer_id_card = { [Op.like]: `%${searchValue}%` };
|
||||
} else if (searchField === 'applicationNumber') {
|
||||
// 数据库中实际没有applicationNumber字段,使用id作为替代
|
||||
where.id = { [Op.like]: `%${searchValue}%` };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +50,17 @@ const getApplications = async (req, res) => {
|
||||
const offset = (parseInt(page) - 1) * parseInt(pageSize);
|
||||
const limit = parseInt(pageSize);
|
||||
|
||||
// 排序参数
|
||||
const order = [[sortField, sortOrder.toUpperCase()]];
|
||||
// 排序参数 - 映射字段名
|
||||
const fieldMapping = {
|
||||
'createdAt': 'created_at',
|
||||
'updatedAt': 'updated_at',
|
||||
'applicationDate': 'application_date',
|
||||
'loanAmount': 'loan_amount',
|
||||
'loanTerm': 'loan_term',
|
||||
'interestRate': 'interest_rate'
|
||||
};
|
||||
const dbSortField = fieldMapping[sortField] || sortField;
|
||||
const order = [[dbSortField, sortOrder.toUpperCase()]];
|
||||
|
||||
// 查询数据
|
||||
const { count, rows } = await LoanApplication.findAndCountAll({
|
||||
|
||||
Reference in New Issue
Block a user