From 990c09c842d87d1f179e3a0070541da0457b8393 Mon Sep 17 00:00:00 2001 From: KKSU <15274802129@163.com> Date: Tue, 21 Nov 2023 14:07:19 +0800 Subject: [PATCH] 匹配 --- src/main/java/cc/mrbird/febs/mall/service/impl/MallNewsInfoServiceImpl.java | 165 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 137 insertions(+), 28 deletions(-) diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/MallNewsInfoServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/MallNewsInfoServiceImpl.java index 2dd07ea..1a68d76 100644 --- a/src/main/java/cc/mrbird/febs/mall/service/impl/MallNewsInfoServiceImpl.java +++ b/src/main/java/cc/mrbird/febs/mall/service/impl/MallNewsInfoServiceImpl.java @@ -2,18 +2,29 @@ import cc.mrbird.febs.common.entity.FebsResponse; import cc.mrbird.febs.common.entity.QueryRequest; +import cc.mrbird.febs.mall.conversion.MallProductNftConversion; +import cc.mrbird.febs.mall.dto.AdminMallProductNftDto; import cc.mrbird.febs.mall.dto.MallNewsInfoDto; -import cc.mrbird.febs.mall.entity.MallNewsInfo; +import cc.mrbird.febs.mall.entity.*; +import cc.mrbird.febs.mall.mapper.MallNewsCategoryMapper; import cc.mrbird.febs.mall.mapper.MallNewsInfoMapper; +import cc.mrbird.febs.mall.mapper.MallProductNftMapper; import cc.mrbird.febs.mall.service.IMallNewsInfoService; import cc.mrbird.febs.mall.vo.AdminMallNewsInfoVo; +import cc.mrbird.febs.mall.vo.AdminMallProductBuyVo; +import cc.mrbird.febs.mall.vo.AdminMallProductNftVo; +import cc.mrbird.febs.mall.vo.AdminMallProductSellVo; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; + +import java.util.List; /** * @author wzy @@ -23,7 +34,10 @@ @Service @RequiredArgsConstructor public class MallNewsInfoServiceImpl extends ServiceImpl<MallNewsInfoMapper, MallNewsInfo> implements IMallNewsInfoService { - + + private final MallNewsCategoryMapper mallNewsCategoryMapper; + private final MallProductNftMapper mallProductNftMapper; + @Override public IPage<AdminMallNewsInfoVo> getNewInfoList(MallNewsInfo mallNewsInfo, QueryRequest request) { Page<AdminMallNewsInfoVo> page = new Page<>(request.getPageNum(), request.getPageSize()); @@ -33,20 +47,27 @@ @Override public FebsResponse addNewsInfo(MallNewsInfoDto mallNewsInfoDto) { - Integer type = mallNewsInfoDto.getType(); - if(type == 2){ - Long goodsId = mallNewsInfoDto.getGoodsId()==null?0L:mallNewsInfoDto.getGoodsId(); - if(goodsId == 0L){ - return new FebsResponse().fail().message("请选择跳转的产品"); - } +// Integer type = mallNewsInfoDto.getType(); +// if(type == 2){ +// Long goodsId = mallNewsInfoDto.getGoodsId()==null?0L:mallNewsInfoDto.getGoodsId(); +// if(goodsId == 0L){ +// return new FebsResponse().fail().message("请选择跳转的产品"); +// } +// } +// MallNewsInfo mallNewsInfo = new MallNewsInfo(); +// mallNewsInfo.setTitle(mallNewsInfoDto.getTitle()); +// mallNewsInfo.setContent(mallNewsInfoDto.getContent()); +// mallNewsInfo.setType(mallNewsInfoDto.getType()); +// if(mallNewsInfoDto.getType() == 2){ +// mallNewsInfo.setTargetId(mallNewsInfoDto.getGoodsId()); +// } + String content = mallNewsInfoDto.getContent(); + if(StrUtil.isNotBlank(content)){ + //正文图片样式居中 + mallNewsInfoDto.setContent(content+"<style>img{max-width:100%!important;}</style>"); } MallNewsInfo mallNewsInfo = new MallNewsInfo(); - mallNewsInfo.setTitle(mallNewsInfoDto.getTitle()); - mallNewsInfo.setContent(mallNewsInfoDto.getContent()); - mallNewsInfo.setType(mallNewsInfoDto.getType()); - if(mallNewsInfoDto.getType() == 2){ - mallNewsInfo.setTargetId(mallNewsInfoDto.getGoodsId()); - } + BeanUtil.copyProperties(mallNewsInfoDto, mallNewsInfo); this.baseMapper.insert(mallNewsInfo); return new FebsResponse().success(); } @@ -67,22 +88,31 @@ if(ObjectUtil.isEmpty(mallNewsInfoBefore)){ return new FebsResponse().fail().message("系统繁忙,请刷新页面重试"); } - Integer type = mallNewsInfoDto.getType(); - if(type == 2){ - Long goodsId = mallNewsInfoDto.getGoodsId()==null?0L:mallNewsInfoDto.getGoodsId(); - if(goodsId == 0L){ - return new FebsResponse().fail().message("请选择跳转的产品"); - } +// Integer type = mallNewsInfoDto.getType(); +// if(type == 2){ +// Long goodsId = mallNewsInfoDto.getGoodsId()==null?0L:mallNewsInfoDto.getGoodsId(); +// if(goodsId == 0L){ +// return new FebsResponse().fail().message("请选择跳转的产品"); +// } +// } +// MallNewsInfo mallNewsInfo = new MallNewsInfo(); +// mallNewsInfo.setTitle(mallNewsInfoDto.getTitle()); +// mallNewsInfo.setContent(mallNewsInfoDto.getContent()); +// mallNewsInfo.setType(mallNewsInfoDto.getType()); +// if(mallNewsInfoDto.getType() == 2){ +// mallNewsInfo.setTargetId(mallNewsInfoDto.getGoodsId()); +// } +// this.baseMapper.insert(mallNewsInfo); +// this.baseMapper.deleteById(mallNewsInfoDto.getId()); + + String content = mallNewsInfoDto.getContent(); + if(StrUtil.isNotBlank(content)){ + //正文图片样式居中 + mallNewsInfoDto.setContent(content+"<style>img{max-width:100%!important;}</style>"); } MallNewsInfo mallNewsInfo = new MallNewsInfo(); - mallNewsInfo.setTitle(mallNewsInfoDto.getTitle()); - mallNewsInfo.setContent(mallNewsInfoDto.getContent()); - mallNewsInfo.setType(mallNewsInfoDto.getType()); - if(mallNewsInfoDto.getType() == 2){ - mallNewsInfo.setTargetId(mallNewsInfoDto.getGoodsId()); - } - this.baseMapper.insert(mallNewsInfo); - this.baseMapper.deleteById(mallNewsInfoDto.getId()); + BeanUtil.copyProperties(mallNewsInfoDto, mallNewsInfo); + this.baseMapper.updateById(mallNewsInfo); return new FebsResponse().success(); } @@ -90,4 +120,83 @@ public MallNewsInfo getNewsInfoById(long id) { return this.baseMapper.selectById(id); } + + @Override + public IPage<MallNewsCategory> findNewsCategoryInPage(MallNewsCategory mallNewsCategory, QueryRequest request) { + Page<MallNewsCategory> page = new Page<>(request.getPageNum(), request.getPageSize()); + return mallNewsCategoryMapper.selectInPage(mallNewsCategory, page); + } + + @Override + public void addOrModifyNewsCategory(MallNewsCategory mallNewsCategory) { + if (mallNewsCategory.getId() != null) { + mallNewsCategoryMapper.updateById(mallNewsCategory); + return; + } + mallNewsCategoryMapper.insert(mallNewsCategory); + } + + @Override + public MallNewsCategory findNewsCategoryById(Long id) { + return mallNewsCategoryMapper.selectById(id); + } + + @Override + public List<MallNewsCategory> findAllCategory() { + return mallNewsCategoryMapper.selectList(null); + } + + @Override + public FebsResponse delNewsCategoryInfo(Long id) { + MallNewsCategory mallNewsCategory = mallNewsCategoryMapper.selectById(id); + if(ObjectUtil.isEmpty(mallNewsCategory)){ + return new FebsResponse().fail().message("系统繁忙,请刷新页面重试"); + } + mallNewsCategoryMapper.deleteById(id); + return new FebsResponse().success(); + } + + @Override + public IPage<AdminMallProductNftVo> getProductNFTList(MallProductNft mallProductNft, QueryRequest request) { + Page<AdminMallProductNftVo> page = new Page<>(request.getPageNum(), request.getPageSize()); + IPage<AdminMallProductNftVo> adminMallNewsInfoVoIPage = mallProductNftMapper.getProductNFTList(page, mallProductNft); + return adminMallNewsInfoVoIPage; + } + + @Override + public FebsResponse addProductNFT(AdminMallProductNftDto adminMallProductNftDto) { + MallProductNft mallProductNft = MallProductNftConversion.INSTANCE.dtoToEntity(adminMallProductNftDto); + mallProductNftMapper.insert(mallProductNft); + return new FebsResponse().success(); + } + + @Override + public FebsResponse delNFT(Long id) { + MallProductNft mallProductNft = mallProductNftMapper.selectById(id); + if(ObjectUtil.isEmpty(mallProductNft)){ + return new FebsResponse().fail().message("系统繁忙,请刷新页面重试"); + } + mallProductNftMapper.deleteById(id); + return new FebsResponse().success(); + } + + @Override + public FebsResponse nftInfoUpdate(MallProductNft mallProductNft) { + mallProductNftMapper.updateById(mallProductNft); + return new FebsResponse().success(); + } + + @Override + public IPage<AdminMallProductBuyVo> getBuyList(MallProductBuy mallProductBuy, QueryRequest request) { + Page<AdminMallProductBuyVo> page = new Page<>(request.getPageNum(), request.getPageSize()); + IPage<AdminMallProductBuyVo> adminMallProductBuyVoIPage = mallProductNftMapper.getBuyList(page, mallProductBuy); + return adminMallProductBuyVoIPage; + } + + @Override + public IPage<AdminMallProductSellVo> getSellList(MallProductSell mallProductSell, QueryRequest request) { + Page<AdminMallProductSellVo> page = new Page<>(request.getPageNum(), request.getPageSize()); + IPage<AdminMallProductSellVo> adminMallProductSellVoIPage = mallProductNftMapper.getSellList(page, mallProductSell); + return adminMallProductSellVoIPage; + } } -- Gitblit v1.9.1