appbanner图

This commit is contained in:
2026-02-11 10:45:31 +08:00
parent 65f5755422
commit 9714e97a71
6 changed files with 42 additions and 33 deletions
@@ -1,11 +1,9 @@
package org.jeecg.modules.api.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.api.service.SysBannerApiService;
import org.jeecg.modules.system.entity.SysBanner;
import org.jeecg.modules.system.entity.SysBannerDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@@ -13,7 +11,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;
@Slf4j
@@ -31,19 +28,11 @@ public class SysBannerApiController {
return sysBannerApiService.selectBannerList(showLocation);
}
// @Operation(summary = "轮播图-app轮播图列表", description = "轮播图-app轮播图列表")
// @GetMapping(value = "/app/list")
// public Result<List<SysBanner>> appBannerList(@RequestParam(name = "showLocation") String showLocation) {
// Date date = new Date();
// List<SysBanner> list = sysBannerApiService.list(new LambdaQueryWrapper<SysBanner>()
// .select(SysBanner::getId, SysBanner::getPhotoUrl, SysBanner::getJumpUrl, SysBanner::getTfJump, SysBanner::getMemo)
// .eq(SysBanner::getShowLocation, showLocation)
// .eq(SysBanner::getStatus, 1)
// .and(wrapper -> wrapper.eq(SysBanner::getIsLongTermEffective, 1)
// .or(wrapper1 -> wrapper1.eq(SysBanner::getIsLongTermEffective, 0).ge(SysBanner::getStartTime, date).le(SysBanner::getEndTime, date)))
// .orderByDesc(SysBanner::getSort)
// );
// return Result.OK(list);
// }
@Operation(summary = "轮播图-app轮播图列表(返回所有)", description = "查询轮播图列表")
@GetMapping("/selectAllBannerList")
public Result<List<SysBannerDO>> selectAllBannerList() {
return Result.ok(sysBannerApiService.selectAllBannerList());
}
}
@@ -7,4 +7,7 @@ import java.util.List;
public interface SysBannerApiService {
Result<List<SysBannerDO>> selectBannerList(String showLocation);
List<SysBannerDO> selectAllBannerList();
}
@@ -2,6 +2,7 @@ package org.jeecg.modules.api.service.impl;
import com.aliyuncs.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.yulichang.query.MPJLambdaQueryWrapper;
import org.apache.commons.collections4.CollectionUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
@@ -16,6 +17,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@@ -29,19 +31,29 @@ public class SysBannerApiServiceImpl implements SysBannerApiService {
@Override
public Result<List<SysBannerDO>> selectBannerList(String showLocation) {
if (StringUtils.isEmpty(showLocation)) {
return Result.error("请选择展示的位置");
}
List<SysBannerDO> list = healthHolidayMapper.selectBannerList(showLocation);
// 添加长期有效的banner
list.addAll(getLongTermEffectiveBanner(showLocation));
// 去重返回
return Result.ok(list.stream().distinct().collect(Collectors.toList()));
}
@Override
public List<SysBannerDO> selectAllBannerList() {
Date date = new Date();
return sysBannerMapper.selectJoinList(SysBannerDO.class, new MPJLambdaQueryWrapper<SysBanner>()
.selectAll(SysBanner.class)
.eq(SysBanner::getStatus, 1)
.and(wrapper -> wrapper.eq(SysBanner::getIsLongTermEffective, 1)
.or(wrapper1 -> wrapper1.eq(SysBanner::getIsLongTermEffective, 0).ge(SysBanner::getStartTime, date).le(SysBanner::getEndTime, date)))
.orderByAsc(SysBanner::getShowLocation)
.orderByAsc(SysBanner::getSort)
);
}
private List<SysBannerDO> getLongTermEffectiveBanner(String showLocation) {
LambdaQueryWrapper<SysBanner> queryWrapper = GlobalUtils.getLambdaQueryWrapper();
queryWrapper.eq(SysBanner::getIsLongTermEffective, CommonConstant.YES)
@@ -2,6 +2,7 @@ package org.jeecg.modules.system.entity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.jeecg.common.aspect.annotation.Dict;
@Data
public class SysBannerDO {
@@ -17,4 +18,8 @@ public class SysBannerDO {
@Schema(title = "跳转参数")
private String jumpUrl;
@Dict(dicCode = "show_location")
@Schema(title = "展示位置")
private String showLocation;
}
@@ -2,6 +2,7 @@ package org.jeecg.modules.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.yulichang.base.MPJBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.system.entity.SysBanner;
@@ -12,7 +13,7 @@ import org.jeecg.modules.system.entity.SysBanner;
* @Version: V1.0
*/
@Mapper
public interface SysBannerMapper extends BaseMapper<SysBanner> {
public interface SysBannerMapper extends MPJBaseMapper<SysBanner> {
/**
* 分页列表查询
*