| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import cn.hutool.core.collection.ListUtil; |
| | | import cn.hutool.core.lang.Snowflake; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.common.util.ResUtils; |
| | | import com.sandu.ximon.admin.dto.BannerDto; |
| | | import com.sandu.ximon.admin.dto.BannerPositionDto; |
| | | import com.sandu.ximon.admin.param.BannerParam; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.dao.domain.Admin; |
| | | import com.sandu.ximon.dao.domain.Banner; |
| | | import com.sandu.ximon.dao.domain.Client; |
| | | import com.sandu.ximon.dao.mapper.BannerMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | |
| | | private final Snowflake snowflake; |
| | | |
| | | /** |
| | | * 获取banner跳转列表 |
| | | */ |
| | | public List<BannerPositionDto> listPosition() { |
| | | return ListUtil.of(new BannerPositionDto("首页1", 0), new BannerPositionDto("首页2", 1), |
| | | new BannerPositionDto("首页3", 2), new BannerPositionDto("首页4", 3)); |
| | | } |
| | | // /** |
| | | // * 获取banner跳转列表 |
| | | // */ |
| | | // public List<BannerPositionDto> listPosition() { |
| | | // return ListUtil.of(new BannerPositionDto("首页1", 0), new BannerPositionDto("首页2", 1), |
| | | // new BannerPositionDto("首页3", 2), new BannerPositionDto("首页4", 3)); |
| | | // } |
| | | |
| | | /** |
| | | * 添加banner |
| | | */ |
| | | public boolean addBanner(BannerParam bannerParam) { |
| | | public boolean addBanner(BannerParam bannerParam, Client client) { |
| | | Banner banner = new Banner(); |
| | | banner.setId(snowflake.nextId()); |
| | | banner.setBannerUrl(ResUtils.removePrefix(bannerParam.getUrl())); |
| | | banner.setAuthor(SecurityUtils.getUsername()); |
| | | banner.setPosition(bannerParam.getPosition()); |
| | | banner.setBindingAuthor(bannerParam.getBinding_author()); |
| | | if (client != null && client.getSuperiorId() != null) { |
| | | banner.setClientId(client.getSuperiorId()); |
| | | } |
| | | return save(banner); |
| | | } |
| | | |
| | |
| | | throw new BusinessException("找不到banner"); |
| | | } |
| | | Banner update = new Banner(); |
| | | // BeanUtils.copyProperties(bannerParam, update); |
| | | // BeanUtils.copyProperties(bannerParam, update); |
| | | update.setId(bannerId); |
| | | update.setPosition(bannerParam.getPosition()); |
| | | update.setBannerUrl(bannerParam.getUrl()); |
| | | update.setId(bannerId); |
| | | return updateById(update); |
| | | } |
| | | |
| | | /** |
| | | * 删除banner |
| | | * |
| | | * @param bannerId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询banner |
| | | * |
| | | * @return |
| | | */ |
| | | public List<Banner> listBanner() { |
| | | LambdaQueryWrapper<Banner> wrapper = Wrappers.lambdaQuery(Banner.class); |
| | | LambdaQueryWrapper<Banner> wrapper = Wrappers.lambdaQuery(Banner.class).eq(Banner::getBindingAuthor, SecurityUtils.getUserId()) |
| | | .or(wrapper1 -> { |
| | | wrapper1.eq(Banner::getClientId, SecurityUtils.getUserId()); |
| | | }); |
| | | |
| | | List<Banner> list = list(wrapper); |
| | | for (Banner banner : list) { |
| | | banner.setBannerUrl(ResUtils.addPrefix(banner.getBannerUrl())); |