Prechádzať zdrojové kódy

直播间添加排序

lyhzzz 3 rokov pred
rodič
commit
4d03730beb

+ 7 - 2
platform-shop/src/main/java/com/platform/controller/BrandController.java

@@ -19,6 +19,7 @@ import com.platform.vo.BrandBindUserVo;
 import com.platform.vo.BrandRspVo;
 import com.platform.vos.CurrentUserLoginVo;
 import com.platform.vos.TbUser;
+import com.platform.xss.SQLFilter;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -108,7 +109,7 @@ public class BrandController extends AbstractController{
     @GetMapping("/brandBindList")
     @RequiresPermissions("brand:list")
     public Result brandBindList(@RequestParam(name = "page") long page,@RequestHeader String token,
-                           @RequestParam(name = "limit") long limit,
+                           @RequestParam(name = "limit") long limit,String order,String sidx,
                            String sceneName,String brandName,Integer type,Integer livestreamStatus) {
         Long userId = null;
         //如果不是超级管理员,则只能查询本部门及子部门数据
@@ -123,8 +124,12 @@ public class BrandController extends AbstractController{
                 }
             }
         }
+        String orderBy = null;
+        if(!StringUtils.isEmpty(sidx) && !StringUtils.isEmpty(order)){
+            orderBy = SQLFilter.humpToLine(sidx) + " "+ order;
+        }
         IPage<BrandEntity> resultPage = brandService.queryBrandBindList(page , limit , sceneName , brandName,
-                getDeptId() ,type,userId,livestreamStatus);
+                getDeptId() ,type,userId,livestreamStatus,orderBy);
         if(null == resultPage){
             return Result.failure("获取店铺绑定列表失败");
         }

+ 1 - 1
platform-shop/src/main/java/com/platform/service/BrandService.java

@@ -47,7 +47,7 @@ public interface BrandService {
     IPage<BrandEntity> queryBrandList(Long pageNum , Long pageSize , String key);
 
     IPage<BrandEntity> queryBrandBindList(Long pageNum , Long pageSize ,  String sceneName,String brandName,
-                                                 List<Long> deptIdList ,Integer type,Long userId,Integer livestreamStatus);
+                                                 List<Long> deptIdList ,Integer type,Long userId,Integer livestreamStatus,String orderBy);
 
     /**
      * 保存实体

+ 6 - 3
platform-shop/src/main/java/com/platform/service/impl/BrandServiceImpl.java

@@ -78,7 +78,7 @@ public class BrandServiceImpl implements BrandService {
 
     @Override
     public IPage<BrandEntity> queryBrandBindList(Long pageNum, Long pageSize,  String sceneName,String brandName,
-                                                 List<Long> deptIdList , Integer type,Long userId,Integer livestreamStatus) {
+                                                 List<Long> deptIdList , Integer type,Long userId,Integer livestreamStatus,String orderBy) {
         QueryWrapper<BrandEntity> queryWrapper = new QueryWrapper<>();
         if(org.apache.commons.lang3.StringUtils.isNotBlank(sceneName)){
             queryWrapper.like("brand.name" , sceneName);
@@ -99,8 +99,11 @@ public class BrandServiceImpl implements BrandService {
         }
         queryWrapper.groupBy("brand.id");
         //这里投机取巧使用id来代替创建时间来做倒序,历史原因,原来的表没创建时间这个字段
-        queryWrapper.orderByDesc("brand.id");
-        queryWrapper.orderByAsc("userBrand.user_id");
+        if(StringUtils.isNotBlank(orderBy)){
+            queryWrapper.last("order by brand."+ orderBy);
+        }else {
+            queryWrapper.orderByDesc("brand.id");
+        }
         IPage<BrandEntity> page = new Page<>(pageNum , pageSize);
         IPage<BrandEntity> resultPage = new Page<>();
         resultPage = brandDao.getBrandBindListWithPage(page , queryWrapper);