|  |  |  | 
|---|
|  |  |  | import cc.mrbird.febs.common.entity.FebsResponse; | 
|---|
|  |  |  | import cc.mrbird.febs.common.entity.QueryRequest; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.dto.MallNewsInfoDto; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.entity.MallNewsCategory; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.entity.MallNewsInfo; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.mapper.MallNewsCategoryMapper; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.mapper.MallNewsInfoMapper; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.service.IMallNewsInfoService; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.vo.AdminMallNewsInfoVo; | 
|---|
|  |  |  | import cn.hutool.core.bean.BeanUtil; | 
|---|
|  |  |  | import cn.hutool.core.util.ObjectUtil; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | 
|---|
|  |  |  | import lombok.RequiredArgsConstructor; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author wzy | 
|---|
|  |  |  | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | @RequiredArgsConstructor | 
|---|
|  |  |  | public class MallNewsInfoServiceImpl extends ServiceImpl<MallNewsInfoMapper, MallNewsInfo> implements IMallNewsInfoService { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private final MallNewsCategoryMapper mallNewsCategoryMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public IPage<AdminMallNewsInfoVo> getNewInfoList(MallNewsInfo mallNewsInfo, QueryRequest request) { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @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()); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | 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()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|