Administrator 4 жил өмнө
parent
commit
61aeac5c16

+ 2 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/front/GalleryController.java

@@ -38,7 +38,7 @@ public class GalleryController {
         return AjaxResult.success(galleryCategoryDtos);
     }
 
-    @ApiOperation("获取分类接口")
+    @ApiOperation("门户菜单点击获取分类接口")
     @GetMapping("/categories")
     public AjaxResult categories(
             @RequestParam("categoryCode") String categoryCode,
@@ -50,7 +50,7 @@ public class GalleryController {
         return AjaxResult.success(result);
     }
 
-    @ApiOperation("根据上级获取下级分类接口")
+    @ApiOperation("门户点击缩略图使用/根据上级获取下级分类接口")
     @GetMapping("/child/categories")
     public AjaxResult childCategories(@RequestParam("parentId") Long parentId) {
         List<GalleryCategoryDto> result = galleryCategoryService.getChildList(parentId);

+ 6 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/grallery/ZbGallery.java

@@ -96,4 +96,10 @@ public class ZbGallery extends BaseEntity {
      */
     @Excel(name = "分类id")
     private Long categoryId;
+
+    /**
+     * 排序顺序
+     */
+    @Excel(name = "排序")
+    private Integer sort;
 }

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/system/dto/GalleryDto.java

@@ -76,6 +76,9 @@ public class GalleryDto implements Serializable {
     @JsonProperty("imgInfos")
     private List<ImgInfosDTO> imgInfos;
 
+    @JsonProperty("sort")
+    private Integer sort;
+
 
     @NoArgsConstructor
     @Data

+ 8 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/ZbGalleryCategoryMapper.java

@@ -1,5 +1,6 @@
 package com.ruoyi.system.mapper;
 
+import com.baomidou.mybatisplus.annotation.SqlParser;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.system.domain.grallery.ZbGalleryCategory;
@@ -24,6 +25,13 @@ public interface ZbGalleryCategoryMapper extends BaseMapper<ZbGalleryCategory> {
      */
     List<ZbGalleryCategory> selectZbGalleryCategoryList(@Param("obj") ZbGalleryCategory zbGalleryCategory, Page<ZbGalleryCategory> page);
 
+
+    /**
+     * 后台查询图库分类/获取首页分类接口
+     * @param zbGalleryCategory
+     * @param page 分页
+     * @return
+     */
     List<GalleryCategoryDto> selectGalleryCategory(@Param("obj") ZbGalleryCategory zbGalleryCategory, Page<ZbGalleryCategory> page);
 
     GalleryCategoryDto getDetailById(@Param("categoryId") Long categoryId);

+ 2 - 4
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ZbGalleryServiceImpl.java

@@ -28,10 +28,7 @@ import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.StringJoiner;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -165,6 +162,7 @@ public class ZbGalleryServiceImpl extends ServiceImpl<ZbGalleryMapper, ZbGallery
         GalleryDto galleryDto = new GalleryDto();
         BeanUtils.copyBeanProp(galleryDto, gallery);
         galleryDto.setId(gallery.getId());
+        galleryDto.setSort(gallery.getSort());
         List<GalleryImgDto> galleryImg = galleryImgService.getByGalleryId(id);
         List<GalleryDto.ImgInfosDTO> infosDTOList = galleryImg.stream().map(x -> {
             GalleryDto.ImgInfosDTO imgInfosDTO = new GalleryDto.ImgInfosDTO();

+ 48 - 29
ruoyi-system/src/main/resources/mapper/system/ZbGalleryCategoryMapper.xml

@@ -20,7 +20,18 @@
     </resultMap>
 
     <sql id="selectZbGalleryCategoryVo">
-        select id, name, code, thumbnail_id, top, parent_id, create_by, create_time, update_by, update_time, remark, show from zb_gallery_category
+        select id,
+               name,
+               code,
+               thumbnail_id,
+               top,
+               parent_id,
+               create_by,
+               create_time,
+               update_by,
+               update_time,
+               remark, show
+        from zb_gallery_category
     </sql>
 
     <select id="selectZbGalleryCategoryList" parameterType="com.ruoyi.system.domain.grallery.ZbGalleryCategory"
@@ -41,9 +52,8 @@
                     and parent_id = #{obj.parentId}
                 </if>
             </if>
-
         </where>
-        order by sort, name
+        order by code , sort, convert(name using gbk)
     </select>
 
 
@@ -66,31 +76,34 @@
                 </if>
             </if>
         </where>
-        order by zgc.sort , zgc.name
+        order by zgc.code DESC, zgc.sort, zgcp.name,convert(zgc.name using gbk)
     </select>
     <select id="getDetailById" resultType="com.ruoyi.system.dto.GalleryCategoryDto">
-         SELECT
-            zgc.*,
-            zgcp.name AS parent,
-            zf.url as thumbnail
-        FROM
-            zb_gallery_category zgc
-            LEFT JOIN zb_file zf ON zgc.thumbnail_id = zf.id
-            LEFT JOIN zb_gallery_category zgcp ON zgc.parent_id = zgcp.id
-            where 1=1 and zgc.id = #{categoryId}
+        SELECT zgc.*,
+               zgcp.name AS parent,
+               zf.url    as thumbnail
+        FROM zb_gallery_category zgc
+                 LEFT JOIN zb_file zf ON zgc.thumbnail_id = zf.id
+                 LEFT JOIN zb_gallery_category zgcp ON zgc.parent_id = zgcp.id
+        where 1 = 1
+          and zgc.id = #{categoryId}
     </select>
+
     <select id="selectGalleryCategoryByParentCode" resultType="com.ruoyi.system.dto.GalleryCategoryDto">
-         SELECT
-            zgc.*,
-            zgcp.name AS parent,
-            zf.url as thumbnail
+        SELECT
+        zgc.*,
+        zgcp.name AS parent,
+        zf.url as thumbnail
         FROM
-            zb_gallery_category zgc
-            JOIN zb_gallery_category zgcp ON zgc.parent_id = zgcp.id
-            LEFT JOIN zb_file zf ON zgc.thumbnail_id = zf.id
-            where 1=1 and zgcp.code = #{categoryCode} and zgcp.top = 1
-            order by zgc.sort, zgc.name
+        zb_gallery_category zgc
+        JOIN zb_gallery_category zgcp ON zgc.parent_id = zgcp.id
+        LEFT JOIN zb_file zf ON zgc.thumbnail_id = zf.id
+        <where>
+            zgcp.top = 1 and zgcp.code = #{categoryCode}
+        </where>
+        order by zgc.code DESC,zgc.sort,zgcp.name,convert(zgc.name using gbk)
     </select>
+
     <select id="getByParentIds" resultType="com.ruoyi.system.dto.GalleryCategoryDto">
         SELECT
         zgc.*,
@@ -100,16 +113,22 @@
         zb_gallery_category zgc
         LEFT JOIN zb_file zf ON zgc.thumbnail_id = zf.id
         LEFT JOIN zb_gallery_category zgcp ON zgc.parent_id = zgcp.id
-        where 1=1 and zgc.parent_id in
-        <foreach collection="parentIds" item="item" open="(" close=")" separator=",">
-            #{item}
-        </foreach>
-        order by zgc.sort, zgc.name
+        <if test="parentIds != null and parentIds.size() > 0">
+            <where>zgc.parent_id in
+                <foreach collection="parentIds" open="(" close=")" item="item" separator=",">
+                    #{item}
+                </foreach>
+            </where>
+        </if>
+        order by zgc.code DESC, zgc.sort,zgcp.name,convert(zgc.name using gbk)
     </select>
     <select id="checkHasChildren" resultType="java.lang.Integer">
-        select 1 from zb_gallery_category where parent_id = #{parentId} limit 1
+        select 1
+        from zb_gallery_category
+        where parent_id = #{parentId}
+        limit 1
     </select>
     <select id="getChildrens" resultType="java.lang.String">
-         select getCategoryChildLst(#{parentId}) as childs
+        select getCategoryChildLst(#{parentId}) as childs
     </select>
 </mapper>

+ 7 - 6
ruoyi-system/src/main/resources/mapper/system/ZbGalleryMapper.xml

@@ -68,7 +68,7 @@
                 </if>
             </if>
         </where>
-        order by zg.create_time DESC
+        order by zg.category DESC, zg.sort, zg.latin_name is null, zg.latin_name, CONVERT(zg.cn_name USING gbk)
     </select>
 
     <resultMap id="GalleryDtoMap" type="com.ruoyi.system.dto.GalleryDto">
@@ -131,12 +131,13 @@
         LEFT JOIN zb_file zf ON zf.id = zgi.thumb_id
         left join zb_gallery_category zgc on zgc.id = zg.category_id
         <if test="categoryIds != null and categoryIds.size() > 0">
-            WHERE zg.category_id in
-            <foreach collection="categoryIds" open="(" close=")" item="item" separator=",">
-                #{item}
-            </foreach>
+            <where>zg.category_id in
+                <foreach collection="categoryIds" open="(" close=")" item="item" separator=",">
+                    #{item}
+                </foreach>
+            </where>
         </if>
-        ORDER BY zg.name
+        order by zg.category DESC, zg.sort, zg.latin_name is null, zg.latin_name ,CONVERT(zg.cn_name USING gbk)
     </select>
 
     <select id="checkCategoryHasValue" resultType="java.lang.Integer">