Browse Source

轮播列表增加权重

wwl 4 years ago
parent
commit
8a2c48a478

+ 3 - 0
zzjs-service/src/main/java/com/miaxis/carousel/domain/CarouselChartInfo.java

@@ -47,6 +47,9 @@ public class CarouselChartInfo extends BaseBusinessEntity{
     @ApiModelProperty(value = "跳转url类型  goMiniApp:小程序 、goPage:小程序页面、goWebView: h5")
     private String jumpUrlType;
 
+    @ApiModelProperty(value = "权重(数值从大到小)")
+    private Integer weight;
+
     /** 状态  0:有效(默认)、1:失效 (伪删除) */
     @Excel(name = "状态  0:有效(默认)、1:失效 (伪删除)", readConverterExp = "伪=删除")
     @TableField("status")

+ 6 - 1
zzjs-service/src/main/java/com/miaxis/carousel/service/impl/CarouselChartInfoServiceImpl.java

@@ -20,8 +20,10 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
  * 轮播图Service业务层处理
@@ -138,7 +140,10 @@ public class CarouselChartInfoServiceImpl extends ServiceImpl<CarouselChartInfoM
             carouselChartInfo.setStatus(0);//启用状态
             infoVos = carouselChartInfoMapper.selectCarouselChartInfoList(carouselChartInfo);
         }
-        return infoVos;
+
+        return infoVos.stream()
+                .sorted(Comparator.comparing(CarouselChartInfoVo::getWeight).reversed())
+                .collect(Collectors.toList());
     }
 
 

+ 4 - 0
zzjs-service/src/main/java/com/miaxis/carousel/vo/CarouselChartInfoVo.java

@@ -41,8 +41,12 @@ public class CarouselChartInfoVo{
     @ApiModelProperty(value = "跳转url类型  goMiniApp:小程序 、goPage:小程序页面 、goWebView: h5")
     private String jumpUrlType;
 
+    @ApiModelProperty(value = "权重(数值从大到小)")
+    private Integer weight;
+
     /** 状态  0:有效(默认)、1:失效 (伪删除) */
     @ApiModelProperty(value = "状态  0:有效(默认)、1:失效 (伪删除)")
     private Integer status;
 
+
 }

+ 5 - 1
zzjs-service/src/main/resources/mapper/carousel/CarouselChartInfoMapper.xml

@@ -12,11 +12,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="jump_url_type"    column="jumpUrlType"    />
         <result property="createTime"    column="create_time"    />
         <result property="updateTime"    column="update_time"    />
+        <result property="weight"    column="weight"    />
         <result property="status"    column="status"    />
     </resultMap>
 
     <sql id="selectCarouselChartInfoVo">
-        select id, picture_name, file_id ,jump_url, jump_url_type, create_time, update_time, status from carousel_chart_info
+        select id, picture_name, file_id ,jump_url, jump_url_type, create_time, update_time, weight, status from carousel_chart_info
     </sql>
 
     <select id="selectCarouselChartInfoList" resultType="com.miaxis.carousel.vo.CarouselChartInfoVo">
@@ -27,6 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ci.jump_url as jumpUrl,
         ci.jump_url_type as jumpUrlType,
         f.file_url as fileUrl,
+        ci.weight,
         ci.status
         from carousel_chart_info ci
         LEFT JOIN file_info f on f.file_id = ci.file_id
@@ -35,6 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="fileId != null "> and file_id = #{fileId}</if>
             <if test="status != null "> and status = #{status}</if>
         </where>
+        ORDER BY ci.weight DESC
     </select>
 
     <select id="getCarouselChartById" resultType="com.miaxis.carousel.vo.CarouselChartInfoVo">
@@ -45,6 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ci.jump_url as jumpUrl,
         ci.jump_url_type as jumpUrlType,
         f.file_url as fileUrl,
+        ci.weight,
         ci.status
         from carousel_chart_info ci
         LEFT JOIN file_info f on f.file_id = ci.file_id