Showing
1 changed file
with
8 additions
and
6 deletions
| ... | @@ -26,9 +26,9 @@ module.exports = function (dbo) { | ... | @@ -26,9 +26,9 @@ module.exports = function (dbo) { |
| 26 | try { | 26 | try { |
| 27 | // 获取数据 | 27 | // 获取数据 |
| 28 | let params = req.query; | 28 | let params = req.query; |
| 29 | - let {province_name} = params; | 29 | + let {province} = params; |
| 30 | 30 | ||
| 31 | - province_name = province_name || ''; | 31 | + province = province || ''; |
| 32 | 32 | ||
| 33 | // 代码逻辑区域 | 33 | // 代码逻辑区域 |
| 34 | let result = await dbo.query(` | 34 | let result = await dbo.query(` |
| ... | @@ -40,7 +40,7 @@ module.exports = function (dbo) { | ... | @@ -40,7 +40,7 @@ module.exports = function (dbo) { |
| 40 | from days d | 40 | from days d |
| 41 | left join tb_mf_timeline_area ta on ta.update_time::date = d.today | 41 | left join tb_mf_timeline_area ta on ta.update_time::date = d.today |
| 42 | where 1=1 | 42 | where 1=1 |
| 43 | - and province_name ~ :province_name | 43 | + and province_name ~ :province |
| 44 | group by 1,2 | 44 | group by 1,2 |
| 45 | order by 2, 1 | 45 | order by 2, 1 |
| 46 | ) | 46 | ) |
| ... | @@ -58,7 +58,7 @@ module.exports = function (dbo) { | ... | @@ -58,7 +58,7 @@ module.exports = function (dbo) { |
| 58 | from dat | 58 | from dat |
| 59 | group by 1 | 59 | group by 1 |
| 60 | order by 2 desc | 60 | order by 2 desc |
| 61 | - `, {replacements: {province_name}, type: dbo.QueryTypes.SELECT}); | 61 | + `, {replacements: {province}, type: dbo.QueryTypes.SELECT}); |
| 62 | 62 | ||
| 63 | return Result.Ok('成功!', result); | 63 | return Result.Ok('成功!', result); |
| 64 | } catch (e) { | 64 | } catch (e) { |
| ... | @@ -76,8 +76,9 @@ module.exports = function (dbo) { | ... | @@ -76,8 +76,9 @@ module.exports = function (dbo) { |
| 76 | try { | 76 | try { |
| 77 | // 获取数据 | 77 | // 获取数据 |
| 78 | let params = req.query; | 78 | let params = req.query; |
| 79 | - let {date} = params; | 79 | + let {date, province} = params; |
| 80 | date = date || moment().format('YYYY-MM-DD'); | 80 | date = date || moment().format('YYYY-MM-DD'); |
| 81 | + province = province || ''; | ||
| 81 | 82 | ||
| 82 | // 代码逻辑区域 | 83 | // 代码逻辑区域 |
| 83 | let result = await dbo.query(` | 84 | let result = await dbo.query(` |
| ... | @@ -85,12 +86,13 @@ module.exports = function (dbo) { | ... | @@ -85,12 +86,13 @@ module.exports = function (dbo) { |
| 85 | select update_time, province_short_name province, confirmed_count, suspected_count, cured_count, dead_count, "comment", cities, country, row_number() over(partition by province_short_name order by update_time desc) rn | 86 | select update_time, province_short_name province, confirmed_count, suspected_count, cured_count, dead_count, "comment", cities, country, row_number() over(partition by province_short_name order by update_time desc) rn |
| 86 | from tb_mf_timeline_area | 87 | from tb_mf_timeline_area |
| 87 | where update_time::date = :date | 88 | where update_time::date = :date |
| 89 | + and province_name ~ :province | ||
| 88 | ) | 90 | ) |
| 89 | select update_time, province, confirmed_count, suspected_count, cured_count, dead_count, "comment", cities, country | 91 | select update_time, province, confirmed_count, suspected_count, cured_count, dead_count, "comment", cities, country |
| 90 | from t | 92 | from t |
| 91 | where rn = 1 | 93 | where rn = 1 |
| 92 | order by confirmed_count desc | 94 | order by confirmed_count desc |
| 93 | - `, {replacements: {date}, type: dbo.QueryTypes.SELECT}); | 95 | + `, {replacements: {date, province}, type: dbo.QueryTypes.SELECT}); |
| 94 | 96 | ||
| 95 | return Result.Ok('成功!', result); | 97 | return Result.Ok('成功!', result); |
| 96 | } catch (e) { | 98 | } catch (e) { | ... | ... |
-
Please register or login to post a comment