Browse Source

场景列表排序

lyhzzz 2 years ago
parent
commit
e31897b82e

+ 2 - 0
src/main/java/com/fdkankan/manage/controller/OverallController.java

@@ -35,6 +35,8 @@ public class OverallController {
 
     @PostMapping("/list")
     public ResultData list(@RequestBody OverallParam param){
+
+
         OverallVo vo = overallClient.list(param,appId,key);
         if(vo.getCode() != 0 ){
             return ResultData.error(vo.getCode(),vo.getMsg());

+ 3 - 0
src/main/java/com/fdkankan/manage/httpClient/param/LaserSceneParam.java

@@ -17,4 +17,7 @@ public class LaserSceneParam {
     private String sceneCode;
     private String startTime;
     private String endTime;
+
+    private String orderBy = "shoot_time";
+    private String sortBy = "DESC";
 }

+ 4 - 0
src/main/java/com/fdkankan/manage/httpClient/service/LaserService.java

@@ -117,6 +117,10 @@ public class LaserService {
         }
         BeanUtils.copyProperties(param,newParam);
         newParam.setTitle(param.getSceneName());
+
+        newParam.setOrderBy(param.getFiled());
+        newParam.setSortBy(param.getOrder());
+
         return newParam;
     }
 

+ 24 - 0
src/main/java/com/fdkankan/manage/httpClient/vo/OverallParam.java

@@ -1,5 +1,7 @@
 package com.fdkankan.manage.httpClient.vo;
 
+import com.fdkankan.manage.util.FiledUtil;
+import jodd.util.StringUtil;
 import lombok.Data;
 import org.apache.commons.lang3.StringUtils;
 
@@ -15,6 +17,14 @@ public class OverallParam {
     private String sceneName;
     private String userName;
 
+    private String filed;
+
+    private String order;
+
+    private String orderBy ;
+
+    private String sort ;
+
     public String getSearchKey() {
         if(StringUtils.isNotBlank(sceneName)){
             return sceneName;
@@ -28,4 +38,18 @@ public class OverallParam {
         return userId;
     }
 
+    public String getOrderBy() {
+        if(StringUtil.isNotBlank(filed)){
+            return FiledUtil.upperCharToUnderLine(filed);
+        }
+        return "time";
+    }
+
+    public String getSort() {
+        if(StringUtil.isNotBlank(order) && order.contains("end")){
+            return order.split("end")[0];
+        }
+        return "DESC";
+    }
+
 }

+ 27 - 0
src/main/java/com/fdkankan/manage/util/FiledUtil.java

@@ -0,0 +1,27 @@
+package com.fdkankan.manage.util;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class FiledUtil {
+
+    public static String upperCharToUnderLine(String param) {
+        Pattern p=Pattern.compile("[A-Z]");
+        if(param==null ||param.equals("")){
+            return "";
+        }
+        StringBuilder builder=new StringBuilder(param);
+        Matcher mc=p.matcher(param);
+        int i=0;
+        while (mc.find()) {
+            builder.replace(mc.start()+i, mc.end()+i, "_"+mc.group().toLowerCase());
+            i++;
+        }
+
+        if('_' == builder.charAt(0)){
+            builder.deleteCharAt(0);
+        }
+        return builder.toString();
+    }
+
+}

+ 25 - 0
src/main/java/com/fdkankan/manage/vo/request/SceneParam.java

@@ -1,9 +1,14 @@
 package com.fdkankan.manage.vo.request;
 
+import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.manage.util.Dateutils;
+import com.fdkankan.manage.util.FiledUtil;
 import com.fdkankan.manage.vo.request.RequestBase;
+import jodd.util.StringUtil;
 import lombok.Data;
+import org.springframework.web.bind.annotation.GetMapping;
 
+import java.security.GeneralSecurityException;
 import java.util.List;
 @Data
 public class SceneParam extends RequestBase {
@@ -21,6 +26,10 @@ public class SceneParam extends RequestBase {
     private String startTime;
     private String endTime;
 
+    private String filed;
+
+    private String order;
+
     public String getStartTime() {
         if(timeList != null && timeList.size() >1){
             return Dateutils.getStartTime(timeList.get(0));
@@ -34,4 +43,20 @@ public class SceneParam extends RequestBase {
         }
         return Dateutils.getEndTime(endTime);
     }
+
+    public String getFiled() {
+        if(StringUtil.isNotBlank(filed)){
+            return FiledUtil.upperCharToUnderLine(filed);
+        }
+        return "crate_time";
+    }
+
+    public String getOrder() {
+        if(StringUtil.isNotBlank(order) && order.contains("end")){
+            return order.split("end")[0];
+        }
+        return "DESC";
+    }
+
+
 }

+ 1 - 1
src/main/resources/mapper/manage/SceneMapper.xml

@@ -55,6 +55,6 @@
         <if test="param.endTime !=null and param.endTime !='' ">
             and s.create_time &lt;= #{endTime}
         </if>
-        order by s.id desc
+        order by s.${param.field}  ${param.order}
     </select>
 </mapper>