package com.panzhihua.service_community.service.impl; 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 static java.util.Objects.isNull; @Service public class ComSanShuoEventServiceImpl extends ServiceImpl 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)); } }