Selaa lähdekoodia

Merge branch 'information-27' into dev

zoujiajian 2 vuotta sitten
vanhempi
sitoutus
ab79e678c1

+ 23 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/information/CmsInformationController.java

@@ -75,6 +75,29 @@ public class CmsInformationController {
         return GatewayResponse.SUCCESS.newBuilder().toResult();
     }
 
+
+    /**
+     * 文章排序
+     */
+    @PutMapping("/sorted")
+    public Result<String> sortedInformation(@RequestBody Information information) {
+        if (information.getId() == null) {
+            throw BusinessRuntimeException.getInstance("请指定要排序的文章");
+        }
+        Integer sorted = information.getSorted();
+        if (sorted != null && sorted >= 0) {
+            Information byId = informationService.getById(information.getId());
+            if (byId != null && byId.getSorted() != sorted) {
+                byId.setSorted(sorted);
+                informationService.updateById(byId);
+                Set<String> keys = redisService.keys(RedisService.key.INFORMATION_KEY.getName() + "*");
+                redisService.del(keys.toArray(String[]::new));
+            }
+        }
+        return GatewayResponse.SUCCESS.newBuilder().toResult();
+    }
+
+
     /**
      * 获取文章
      */