zhangtiansen
2022-09-06 c9a036da723b08fc34ecc90c0668348f01e01458
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
package com.panzhihua.service_community.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.panzhihua.common.model.dtos.community.sanshuo.ComSanshuoEventDTO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.service_community.dao.ComSanshuoEventDao;
import com.panzhihua.service_community.entity.ComSanshuoEvent;
import com.panzhihua.service_community.service.ComSanShuoEventService;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
 
import java.util.Date;
import java.util.List;
 
import static java.util.Objects.isNull;
 
@Service
public class ComSanShuoEventServiceImpl  extends ServiceImpl<ComSanshuoEventDao, ComSanshuoEvent> implements ComSanShuoEventService {
 
    @Resource
    private ComSanshuoEventDao sanshuoEventDao;
 
    /**
     * 添加或修改事件类型
     * @param comSanshuoEvent
     * @return  处理结果
     * */
    @Override
    public R addOrUpdate(ComSanshuoEvent comSanshuoEvent) {
        if (isNull(comSanshuoEvent.getName())){
            return R.fail("名称不能为空!");
        }
        if (isNull(comSanshuoEvent.getId())){
            //添加操作
            comSanshuoEvent.setCreateTime(new Date());
            int insert = sanshuoEventDao.insert(comSanshuoEvent);
            if (insert>0){
                return R.ok();
            }
        }
        //修改
        comSanshuoEvent.setUpdateTime(new Date());
        int i = sanshuoEventDao.updateById(comSanshuoEvent);
        if (i>0){
            return R.ok();
        }
        return R.fail("操作失败");
    }
 
    /**
     * 后台获取事件类型列表
     * @param comSanshuoEventDTO
     * @return  处理结果
     * */
    @Override
    public R backStageList(ComSanshuoEventDTO comSanshuoEventDTO) {
        return R.ok(this.baseMapper.pageEvent(new Page(comSanshuoEventDTO.getPage(),comSanshuoEventDTO.getSize()),comSanshuoEventDTO)) ;
    }
}