| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.system.mapper.TSysBannerMapper; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.mapper.*; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.model.TSysBanner; |
| | | import com.ruoyi.system.query.TSysBannerQuery; |
| | | import com.ruoyi.system.service.TSysBannerService; |
| | | import com.ruoyi.system.vo.TSysBannerVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class TSysBannerServiceImpl extends ServiceImpl<TSysBannerMapper, TSysBanner> implements TSysBannerService { |
| | | |
| | | @Autowired |
| | | private TSysEducationalInfoMapper sysEducationalInfoMapper; |
| | | @Autowired |
| | | private TSysLiveMapper sysLiveMapper; |
| | | @Autowired |
| | | private TSysProductIntroductionMapper sysProductIntroductionMapper; |
| | | @Autowired |
| | | private TSysActivityMapper sysActivityMapper; |
| | | |
| | | @Override |
| | | public boolean isExit(TSysBanner dto) { |
| | | if(StringUtils.isNotEmpty(dto.getId())){ |
| | | // 修改 |
| | | return this.count(Wrappers.lambdaQuery(TSysBanner.class).ne(TSysBanner::getId, dto.getId()).eq(TSysBanner::getBannerName, dto.getBannerName())) > 0; |
| | | }else { |
| | | // 新增 |
| | | return this.count(Wrappers.lambdaQuery(TSysBanner.class).eq(TSysBanner::getBannerName, dto.getBannerName())) > 0; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<TSysBannerVO> pageList(TSysBannerQuery query) { |
| | | PageInfo<TSysBannerVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<TSysBannerVO> list = this.baseMapper.pageList(query,pageInfo); |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | return pageInfo; |
| | | } |
| | | for (TSysBannerVO sysBannerVO : list) { |
| | | switch (sysBannerVO.getJumpType()){ |
| | | case 2: |
| | | TSysEducationalInfo educationalInfo = sysEducationalInfoMapper.selectById(sysBannerVO.getContentId()); |
| | | if(Objects.nonNull(educationalInfo)){ |
| | | sysBannerVO.setContentName(educationalInfo.getInfoTitle()); |
| | | } |
| | | break; |
| | | case 3: |
| | | TSysLive sysLive = sysLiveMapper.selectById(sysBannerVO.getContentId()); |
| | | if(Objects.nonNull(sysLive)){ |
| | | sysBannerVO.setContentName(sysLive.getLiveTitle()); |
| | | } |
| | | break; |
| | | case 4: |
| | | TSysProductIntroduction sysProductIntroduction = sysProductIntroductionMapper.selectById(sysBannerVO.getContentId()); |
| | | if(Objects.nonNull(sysProductIntroduction)){ |
| | | sysBannerVO.setContentName(sysProductIntroduction.getProductName()); |
| | | } |
| | | break; |
| | | case 5: |
| | | TSysActivity sysActivity = sysActivityMapper.selectById(sysBannerVO.getContentId()); |
| | | if(Objects.nonNull(sysActivity)){ |
| | | sysBannerVO.setContentName(sysActivity.getActivityName()); |
| | | } |
| | | } |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | } |