banner添加国家选项
(cherry picked from commit 3462a14e0fb6232bb6dccb9d86663ca58ae6b3bb)
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package com.accompany.admin.service;
|
||||
|
||||
import com.accompany.core.model.RegionInfo;
|
||||
import com.accompany.core.service.region.RegionInfoService;
|
||||
import com.accompany.core.vo.RegionInfoVo;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -15,4 +17,15 @@ public class RegionInfoAdminService {
|
||||
public List<RegionInfoVo> getAllList() {
|
||||
return regionInfoService.getAllList();
|
||||
}
|
||||
|
||||
public List<RegionInfo> listByPartitionId(Integer partitionId, Boolean containAll) {
|
||||
List<RegionInfo> regionInfos = regionInfoService.listByPartitionId(partitionId);
|
||||
if (CollectionUtils.isNotEmpty(regionInfos) && containAll) {
|
||||
RegionInfo regionInfo = new RegionInfo();
|
||||
regionInfo.setId(regionInfoService.ALL_REGION);
|
||||
regionInfo.setName("全部");
|
||||
regionInfos.add(0, regionInfo);
|
||||
}
|
||||
return regionInfos;
|
||||
}
|
||||
}
|
||||
|
@@ -6,12 +6,14 @@ import com.accompany.business.service.firstpage.FirstPageBannerService;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.core.mybatismapper.PartitionInfoMapper;
|
||||
import com.accompany.core.service.region.RegionInfoService;
|
||||
import com.accompany.core.util.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -26,6 +28,9 @@ public class FirstPageBannerAdminService {
|
||||
|
||||
@Autowired
|
||||
private PartitionInfoMapper partitionInfoMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private RegionInfoService regionInfoService;
|
||||
|
||||
/**
|
||||
* 获取banner列表
|
||||
@@ -42,7 +47,7 @@ public class FirstPageBannerAdminService {
|
||||
*/
|
||||
public IPage<FirstPageBanner> getFirstPageBannerList(Integer pageNumber, Integer pageSize, Byte skipType,
|
||||
Byte bannerStatus, Byte bannerType, String beginTime,
|
||||
String endTime, String appId, Integer partitionId) {
|
||||
String endTime, String appId, Integer partitionId, Integer regionId) {
|
||||
QueryWrapper<FirstPageBanner> wrapper = new QueryWrapper<>();
|
||||
LambdaQueryWrapper<FirstPageBanner> lambdaQueryWrapper = wrapper.lambda();
|
||||
lambdaQueryWrapper.eq(skipType != null && skipType != 0, FirstPageBanner::getSkipType, skipType)
|
||||
@@ -54,6 +59,9 @@ public class FirstPageBannerAdminService {
|
||||
} else {
|
||||
lambdaQueryWrapper.ne(FirstPageBanner::getBannerType, Constant.BannerType.BANNER_ACTIVITY);
|
||||
}
|
||||
if (regionId != null && regionId != regionInfoService.ALL_REGION) {
|
||||
lambdaQueryWrapper.eq(FirstPageBanner::getRegionId, regionId);
|
||||
}
|
||||
lambdaQueryWrapper.ge(!StringUtils.isEmpty(beginTime), FirstPageBanner::getStartTime, DateTimeUtil.convertStrToDate(beginTime))
|
||||
.le(!StringUtils.isEmpty(endTime), FirstPageBanner::getEndTime, DateTimeUtil.convertStrToDate(endTime))
|
||||
.like(partitionId != null, FirstPageBanner::getPartitionIds, partitionId)
|
||||
|
@@ -7,6 +7,7 @@ import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.core.mybatismapper.PartitionInfoMapper;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.accompany.core.service.region.RegionInfoService;
|
||||
import com.accompany.core.util.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -14,6 +15,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -33,6 +35,9 @@ public class SecondPageBannerAdminService {
|
||||
private PartitionInfoMapper partitionInfoMapper;
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private RegionInfoService regionInfoService;
|
||||
|
||||
/**
|
||||
* 获取banner列表
|
||||
@@ -46,7 +51,7 @@ public class SecondPageBannerAdminService {
|
||||
* @return
|
||||
*/
|
||||
public IPage<SecondPageBanner> getSecondPageBannerList(Integer pageNumber, Integer pageSize, Byte skipType,
|
||||
Byte bannerStatus, Byte bannerType, Integer timeStatus, String appId, Integer partitionId) {
|
||||
Byte bannerStatus, Byte bannerType, Integer timeStatus, String appId, Integer partitionId, Integer regionId) {
|
||||
LambdaQueryWrapper<SecondPageBanner> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||
lambdaQueryWrapper.eq(skipType != null && skipType != 0, SecondPageBanner::getSkipType, skipType)
|
||||
.eq(bannerStatus != null && bannerStatus != 0, SecondPageBanner::getBannerStatus, bannerStatus)
|
||||
@@ -65,6 +70,9 @@ public class SecondPageBannerAdminService {
|
||||
} else if (timeStatus == 3) {//已过期
|
||||
lambdaQueryWrapper.lt(SecondPageBanner::getEndTime, new Date());
|
||||
}
|
||||
if (regionId != null && regionId != regionInfoService.ALL_REGION) {
|
||||
lambdaQueryWrapper.eq(SecondPageBanner::getRegionId, regionId);
|
||||
}
|
||||
lambdaQueryWrapper.eq(SecondPageBanner::getDelTag, Constant.BannerDel.NO_DEL)
|
||||
.like(partitionId != null, SecondPageBanner::getPartitionIds, partitionId)
|
||||
.orderByAsc(SecondPageBanner::getSeqNo)
|
||||
|
@@ -2,6 +2,7 @@ package com.accompany.admin.controller;
|
||||
|
||||
import com.accompany.admin.service.RegionInfoAdminService;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.core.model.RegionInfo;
|
||||
import com.accompany.core.vo.RegionInfoVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -31,4 +32,11 @@ public class RegionInfoAdminController {
|
||||
}
|
||||
return BusiResult.success(allList);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取分区下的国家", httpMethod = "GET")
|
||||
@RequestMapping(value = "/listByPartitionId")
|
||||
public BusiResult<List<RegionInfo>> listByPartitionId(Integer partitionId, Boolean containAll) {
|
||||
List<RegionInfo> allList = regionInfoAdminService.listByPartitionId(partitionId, containAll);
|
||||
return BusiResult.success(allList);
|
||||
}
|
||||
}
|
||||
|
@@ -68,9 +68,11 @@ public class FirstPageBannerAdminController extends BaseController {
|
||||
|
||||
@ApiOperation("获取banner列表")
|
||||
@GetMapping(value = "/list")
|
||||
public Pagination<FirstPageBanner> getFirstPageBannerList(Byte skipType, Byte bannerStatus, Byte bannerType, String beginTime, String endTime, String appId, Integer partitionId) {
|
||||
public Pagination<FirstPageBanner> getFirstPageBannerList(Byte skipType, Byte bannerStatus, Byte bannerType,
|
||||
String beginTime, String endTime, String appId,
|
||||
Integer partitionId, Integer regionId) {
|
||||
IPage<FirstPageBanner> pageInfo = firstPageBannerAdminService.getFirstPageBannerList(getPageNumber(), getPageSize(),
|
||||
skipType, bannerStatus, bannerType,beginTime,endTime,appId, partitionId);
|
||||
skipType, bannerStatus, bannerType,beginTime,endTime,appId, partitionId, regionId);
|
||||
return new Pagination<>(pageInfo);
|
||||
}
|
||||
|
||||
|
@@ -65,9 +65,9 @@ public class SecondPageBannerAdminController extends BaseController {
|
||||
public Pagination<SecondPageBanner> getSecondPageBannerList(Byte skipType, @RequestParam(defaultValue = "0") Byte bannerStatus,
|
||||
Byte bannerType, @RequestParam(defaultValue = "0") Integer timeStatus,
|
||||
String appId, Integer partitionId,
|
||||
@RequestParam(defaultValue = "1") Integer pageNo, @RequestParam(defaultValue = "20") Integer pageSize) {
|
||||
@RequestParam(defaultValue = "1") Integer pageNo, @RequestParam(defaultValue = "20") Integer pageSize, Integer regionId) {
|
||||
IPage<SecondPageBanner> pageInfo = secondPageBannerAdminService.getSecondPageBannerList(pageNo, pageSize,
|
||||
skipType, bannerStatus, bannerType, timeStatus,appId, partitionId);
|
||||
skipType, bannerStatus, bannerType, timeStatus,appId, partitionId, regionId);
|
||||
return new Pagination<>(pageInfo);
|
||||
}
|
||||
|
||||
|
@@ -30,6 +30,8 @@ public class RegionInfoService extends ServiceImpl<RegionInfoMapper, RegionInfo>
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
|
||||
public static final Integer ALL_REGION = 0;
|
||||
|
||||
public List<RegionInfo> listByUid(Long uid) {
|
||||
Users u = usersBaseService.getUsersByUid(uid);
|
||||
if (null == u){
|
||||
@@ -78,4 +80,19 @@ public class RegionInfoService extends ServiceImpl<RegionInfoMapper, RegionInfo>
|
||||
public List<RegionInfoVo> getAllList() {
|
||||
return baseMapper.getAllList();
|
||||
}
|
||||
|
||||
public List<RegionInfo> listByPartitionId(Integer partitionId) {
|
||||
return lambdaQuery().select(RegionInfo::getId, RegionInfo::getPartitionId,
|
||||
RegionInfo::getIcon,
|
||||
RegionInfo::getCode,
|
||||
RegionInfo::getName)
|
||||
.eq(RegionInfo::getPartitionId, partitionId)
|
||||
.orderByAsc(RegionInfo::getSeq)
|
||||
.list();
|
||||
}
|
||||
|
||||
public Map<Integer, String> getRegionName(){
|
||||
return getAllList().stream()
|
||||
.collect(Collectors.toMap(RegionInfo::getId, RegionInfo::getName));
|
||||
}
|
||||
}
|
||||
|
@@ -70,6 +70,8 @@ public class FirstPageBanner implements Serializable {
|
||||
*/
|
||||
@TableField(value = "partition_ids", typeHandler = IntegerListTypeHandler.class,exist = true)
|
||||
private List<Integer> partitionIds;
|
||||
@TableField(value = "region_id")
|
||||
private Integer regionId ;
|
||||
|
||||
/**
|
||||
* 分区描述
|
||||
|
@@ -70,6 +70,8 @@ public class SecondPageBanner implements Serializable {
|
||||
*/
|
||||
@TableField(value = "partition_ids", typeHandler = IntegerListTypeHandler.class,exist = true)
|
||||
private List<Integer> partitionIds;
|
||||
@TableField(value = "region_id")
|
||||
private Integer regionId ;
|
||||
|
||||
/**
|
||||
* 分区描述
|
||||
|
@@ -18,6 +18,7 @@ import com.accompany.common.utils.AppVersionUtil;
|
||||
import com.accompany.common.utils.StringUtils;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.accompany.core.service.region.RegionInfoService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -50,6 +51,8 @@ public class FirstPageBannerService extends ServiceImpl<FirstPageBannerMapper, F
|
||||
private LevelService levelService;
|
||||
@Autowired
|
||||
private FillFactory fillFactory;
|
||||
@Autowired
|
||||
private RegionInfoService regionInfoService;
|
||||
|
||||
private Gson gson = new Gson();
|
||||
|
||||
@@ -89,6 +92,13 @@ public class FirstPageBannerService extends ServiceImpl<FirstPageBannerMapper, F
|
||||
list = list.stream().filter(v -> CollectionUtil.isEmpty(v.getPartitionIds()) || v.getPartitionIds().contains(u.getPartitionId())).collect(Collectors.toList());
|
||||
list = list.stream().filter(banner -> banner.getEndTime() != null && banner.getStartTime() != null
|
||||
&& now.compareTo(banner.getStartTime()) >= 0 && now.compareTo(banner.getEndTime()) <= 0).collect(Collectors.toList());
|
||||
if (u.getRegionId() == null) {
|
||||
list = list.stream().filter(v -> regionInfoService.ALL_REGION.equals(v.getRegionId()))
|
||||
.collect(Collectors.toList());
|
||||
} else {
|
||||
list = list.stream().filter(v -> regionInfoService.ALL_REGION.equals(v.getRegionId()) || u.getRegionId().equals(v.getRegionId()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
List<FirstPageBannerVo> bannerVos = new ArrayList<>();
|
||||
list.forEach(banner -> {
|
||||
if (StringUtils.isNotBlank(banner.getNoShowChannels()) && StringUtils.isNotBlank(deviceInfo.getChannel())) {
|
||||
|
@@ -17,6 +17,7 @@ import com.accompany.common.utils.AppVersionUtil;
|
||||
import com.accompany.common.utils.StringUtils;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.accompany.core.service.region.RegionInfoService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@@ -47,6 +48,8 @@ public class SecondPageBannerService extends ServiceImpl<SecondPageBannerMapper,
|
||||
private LevelExperienceMapper levelExperienceMapper;
|
||||
@Autowired
|
||||
private LevelService levelService;
|
||||
@Autowired
|
||||
private RegionInfoService regionInfoService;
|
||||
|
||||
private Gson gson = new Gson();
|
||||
|
||||
@@ -91,7 +94,15 @@ public class SecondPageBannerService extends ServiceImpl<SecondPageBannerMapper,
|
||||
list = list.stream().filter(banner -> banner.getEndTime() != null && banner.getStartTime() != null
|
||||
&& now.compareTo(banner.getStartTime()) >= 0 && now.compareTo(banner.getEndTime()) <= 0
|
||||
&& ("all".equalsIgnoreCase(banner.getPlatform()) || deviceInfo.getOs().equalsIgnoreCase(banner.getPlatform()))).collect(Collectors.toList());
|
||||
if (u.getRegionId() == null) {
|
||||
list = list.stream().filter(v -> regionInfoService.ALL_REGION.equals(v.getRegionId()))
|
||||
.collect(Collectors.toList());
|
||||
} else {
|
||||
list = list.stream().filter(v -> regionInfoService.ALL_REGION.equals(v.getRegionId()) || u.getRegionId().equals(v.getRegionId()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
List<SecondPageBannerVo> bannerVos = new ArrayList<>();
|
||||
|
||||
list.forEach(banner -> {
|
||||
if (StringUtils.isNotBlank(banner.getNoShowChannels()) && StringUtils.isNotBlank(deviceInfo.getChannel())) {
|
||||
// 检查是否不展示的渠道包
|
||||
|
Reference in New Issue
Block a user