1a41cb3b 张雷

fix(equipment): 修复设备列表排序字段转换错误

- 新增 getFiledName 方法,用于将前端传入的字段代码转换为数据库字段名
- 在设备列表查询中使用 getFiledName 方法,确保排序字段的正确性
- 默认排序字段改为 create_time,提高用户体验
1 个父辈 bbf071e3
...@@ -557,7 +557,7 @@ public class EquipmentController { ...@@ -557,7 +557,7 @@ public class EquipmentController {
557 .like(StringUtils.isNotEmpty(installPosition), EquipmentInfo::getInstallPosition, installPosition) 557 .like(StringUtils.isNotEmpty(installPosition), EquipmentInfo::getInstallPosition, installPosition)
558 .eq(StringUtils.isNotEmpty(equipmentDTO.getEquipmentInfo().getId()), "equipment_info.id", equipmentDTO.getEquipmentInfo().getId()); 558 .eq(StringUtils.isNotEmpty(equipmentDTO.getEquipmentInfo().getId()), "equipment_info.id", equipmentDTO.getEquipmentInfo().getId());
559 if (StringUtils.isNotEmpty(orderFiled)) { 559 if (StringUtils.isNotEmpty(orderFiled)) {
560 base.orderBy(true,orderType,"equipment_info." + orderFiled); 560 base.orderBy(true,orderType,"equipment_info." + getFiledName(orderFiled));
561 }else { 561 }else {
562 base.orderBy(true,false,"equipment_info.create_time"); 562 base.orderBy(true,false,"equipment_info.create_time");
563 } 563 }
...@@ -612,6 +612,21 @@ public class EquipmentController { ...@@ -612,6 +612,21 @@ public class EquipmentController {
612 return result; 612 return result;
613 } 613 }
614 614
615 public String getFiledName(String filedCode) {
616 Map<String,String> map = new HashMap<>();
617 map.put("createTime","create_time");
618 map.put("equipmentName","equipment_name");
619 map.put("departId_dictText","depart_id");
620 map.put("equipmentType_dictText","equipment_type");
621 map.put("equipmentStatus_dictText","equipment_status");
622 map.put("equipmentHealthStatus_dictText","equipment_health_status");
623 if(map.get(filedCode)!=null){
624 return map.get(filedCode);
625 }else{
626 return "create_time";
627 }
628 }
629
615 @CustomExceptionAnno(description = "设备-采集实时数据") 630 @CustomExceptionAnno(description = "设备-采集实时数据")
616 @AutoLog(value = "设备-采集实时数据") 631 @AutoLog(value = "设备-采集实时数据")
617 @ApiOperation(value = "设备-采集实时数据", notes = "设备-采集实时数据") 632 @ApiOperation(value = "设备-采集实时数据", notes = "设备-采集实时数据")
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!