lidongdong
2022-12-06 229223286a57c66beac1fa411c8494f64495abfc
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.dg.core.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dg.core.ResultData;
import com.dg.core.db.gen.entity.ClassifyAdministration;
import com.dg.core.db.gen.entity.Slideshow;
import com.dg.core.db.gen.entity.SysUser;
import com.dg.core.db.gen.mapper.SlideshowMapper;
import com.dg.core.service.ISlideshowService;
import org.springframework.stereotype.Service;
 
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
 
@Service
public class SlideshowServiceImpl extends ServiceImpl<SlideshowMapper, Slideshow> implements ISlideshowService {
 
 
    @Override
    public List<Slideshow> selectConfigList(IPage<SysUser> page, Integer state) {
        return null;
    }
 
    @Override
    public List<Slideshow> selectList() {
        return baseMapper.selectList(new QueryWrapper<Slideshow>().lambda());
    }
 
    @Override
    public Slideshow queryById(Integer id) {
        return baseMapper.selectOne(new QueryWrapper<Slideshow>().lambda().eq(Slideshow::getId, id));
    }
 
    @Override
    public ResultData add(Slideshow slideshow) {
        if (slideshow.getUrl() == null || slideshow.getUrl() == "")
            return ResultData.error("图片地址不能为空");
        if (slideshow.getLinkType() == null)
            return ResultData.error("跳转链接类型不能为空");
        if (slideshow.getLinkType().equals(2)) {
            if (slideshow.getTitle() == null || slideshow.getTitle() == "")
                return ResultData.error("类型为富文本时,标题不能为空");
            if (slideshow.getContent() == null || slideshow.getContent() == "")
                return ResultData.error("类型为富文本时,富文本内容不能为空");
        }
        if (slideshow.getLinkType().equals(3) && (slideshow.getLink() == null || slideshow.getLink() == ""))
            return ResultData.error("类型为微信文章时,文章链接容不能为空");
        slideshow.setCreateTime(LocalDateTime.now());
        return ResultData.success(baseMapper.insert(slideshow));
    }
 
    @Override
    public ResultData update(Slideshow slideshow) {
        if (slideshow.getUrl() == null || slideshow.getUrl() == "")
            return ResultData.error("图片地址不能为空");
        if (slideshow.getLinkType() == null)
            return ResultData.error("跳转链接类型不能为空");
        if (slideshow.getLinkType().equals(2)) {
            if (slideshow.getTitle() == null || slideshow.getTitle() == "")
                return ResultData.error("类型为富文本时,标题不能为空");
            if (slideshow.getContent() == null || slideshow.getContent() == "")
                return ResultData.error("类型为富文本时,富文本内容不能为空");
        }
        if (slideshow.getLinkType().equals(3) && (slideshow.getLink() == null || slideshow.getLink() == ""))
            return ResultData.error("类型为微信文章时,文章链接容不能为空");
        return ResultData.success(baseMapper.updateById(slideshow));
 
    }
 
    @Override
    public ResultData delete(Integer id) {
        int i = baseMapper.deleteById(id);
        if (i > 0)
            return ResultData.success();
        else
            return ResultData.error();
    }
 
}