Jelajahi Sumber

教育、精品典藏-排序功能

wuweihao 3 tahun lalu
induk
melakukan
d1b504bc4b

+ 7 - 0
gis_cms/src/main/java/com/gis/cms/controller/GoodsController.java

@@ -92,6 +92,13 @@ public class GoodsController {
         return entityService.display(id, display);
     }
 
+    @ApiOperation(value = "排序", notes = "sort: 序号")
+    @GetMapping(value = "sort/{id}/{sort}")
+    public Result sort(@PathVariable Integer sort, @PathVariable Long id) {
+        entityService.setSort(id, sort);
+        return Result.success();
+    }
+
 
 
 

+ 1 - 1
gis_cms/src/main/java/com/gis/cms/controller/ModuleController.java

@@ -35,7 +35,7 @@ public class ModuleController {
         LambdaQueryWrapper<ModuleEntity> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(ModuleEntity::getModule, module);
         wrapper.orderByDesc(ModuleEntity::getIsDefault);
-        wrapper.orderByDesc(ModuleEntity::getCreateTime);
+//        wrapper.orderByDesc(ModuleEntity::getCreateTime);
         return Result.success(entityService.list(wrapper));
     }
 

+ 7 - 0
gis_cms/src/main/java/com/gis/cms/controller/NewsController.java

@@ -73,4 +73,11 @@ public class NewsController {
     public Result upload(MultipartFile file, @PathVariable String type) {
         return entityService.upload(file, type);
     }
+
+    @ApiOperation(value = "排序", notes = "sort: 序号")
+    @GetMapping(value = "sort/{id}/{sort}")
+    public Result sort(@PathVariable Integer sort, @PathVariable Long id) {
+        entityService.setSort(id, sort);
+        return Result.success();
+    }
 }

+ 3 - 0
gis_cms/src/main/java/com/gis/cms/entity/po/NewsEntity.java

@@ -44,6 +44,9 @@ public class NewsEntity extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "链接, type:share才有值")
     private String shareUrl;
 
+    @ApiModelProperty(value = "排序,倒序排,默认为:1", notes = "排序值倒序>发布时间倒序")
+    private Integer sort;
+
     @ApiModelProperty(value = "模块id")
     private Long moduleId;
 

+ 3 - 0
gis_cms/src/main/java/com/gis/cms/mapper/NewsMapper.java

@@ -16,6 +16,9 @@ public interface NewsMapper extends BaseMapper<NewsEntity> {
     @Update("update tb_news set visit = visit + 1 , update_time = NOW() where is_delete = 0  and id = #{id}")
     void addVisit(Long id);
 
+    @Update("update tb_news set sort = #{sort} , update_time = NOW() where is_delete=0 and id = #{id} ")
+    void setSort(Long id, Integer sort);
+
 
 
 }

+ 2 - 0
gis_cms/src/main/java/com/gis/cms/service/NewsService.java

@@ -35,6 +35,8 @@ public interface NewsService extends IService<NewsEntity> {
 
     Result upload(MultipartFile file, String type);
 
+    void setSort(Long id, Integer sort);
+
 
 
 

+ 5 - 0
gis_cms/src/main/java/com/gis/cms/service/impl/NewsServiceImpl.java

@@ -153,6 +153,11 @@ public class NewsServiceImpl extends ServiceImpl<NewsMapper, NewsEntity> impleme
         return  Result.success(entity);
     }
 
+    @Override
+    public void setSort(Long id, Integer sort) {
+        getBaseMapper().setSort(id, sort);
+    }
+