huliguo
2025-06-04 7e9508a252df668c3f7472be02595c79b21be11a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.ruoyi.system.service.impl;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.system.mapper.BannerMapper;
import com.ruoyi.system.domain.Banner;
import com.ruoyi.system.pojo.dto.AddBannerDTO;
import com.ruoyi.system.pojo.dto.EditBannerDTO;
import com.ruoyi.system.pojo.vo.BannerPageVO;
import com.ruoyi.system.service.BannerService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
 
 
@Service
public class BannerServiceImpl extends ServiceImpl<BannerMapper, Banner> implements BannerService {
 
    @Override
    public IPage<BannerPageVO> getBannerPage(Integer pageNum, Integer pageSize, String name) {
        IPage<BannerPageVO> page=new Page<>(pageNum, pageSize);
        return this.baseMapper.getBannerPage(page,name);
    }
 
    @Override
    public void add(AddBannerDTO dto) {
        Banner banner = new Banner();
        BeanUtils.copyProperties(dto, banner);
        this.baseMapper.insert(banner);
    }
 
    @Override
    public void edit(EditBannerDTO dto) {
        Banner banner = this.getById(dto.getId());
        if (null == banner || banner.getDelFlag() != 0 ) {
            throw new ServiceException("banner不存在");
        }
        BeanUtils.copyProperties(dto, banner);
        this.baseMapper.updateById(banner);
    }
 
    @Override
    public void delete(Integer id) {
        Banner banner = this.baseMapper.selectById(id);
        if (null == banner || banner.getDelFlag() != 0 ) {
            throw new ServiceException("banner不存在");
        }
        banner.setDelFlag(1);
        this.baseMapper.updateById(banner);
    }
}