package com.dl.system.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.dl.common.core.domain.PageQuery; import com.dl.common.core.page.TableDataInfo; import com.dl.common.utils.StringUtils; import com.dl.system.domain.SysNotice; import com.dl.system.mapper.SysNoticeMapper; import com.dl.system.service.ISysNoticeService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import java.util.Arrays; import java.util.List; import java.util.UUID; /** * 公告 服务层实现 * * @author Lion Li */ @RequiredArgsConstructor @Service public class SysNoticeServiceImpl implements ISysNoticeService { private final SysNoticeMapper baseMapper; @Override public TableDataInfo selectPageNoticeList(SysNotice notice, PageQuery pageQuery) { LambdaQueryWrapper lqw = new LambdaQueryWrapper() .like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle()) .eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType()) .like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy()); Page page = baseMapper.selectPage(pageQuery.build(), lqw); return TableDataInfo.build(page); } /** * 查询公告信息 * * @param noticeId 公告ID * @return 公告信息 */ @Override public SysNotice selectNoticeById(String noticeId) { return baseMapper.selectById(noticeId); } /** * 查询公告列表 * * @param notice 公告信息 * @return 公告集合 */ @Override public List selectNoticeList(SysNotice notice) { return baseMapper.selectList(new LambdaQueryWrapper() .like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle()) .eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType()) .like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy())); } /** * 新增公告 * * @param notice 公告信息 * @return 结果 */ @Override public int insertNotice(SysNotice notice) { notice.setNoticeId(UUID.randomUUID().toString()); return baseMapper.insert(notice); } /** * 修改公告 * * @param notice 公告信息 * @return 结果 */ @Override public int updateNotice(SysNotice notice) { return baseMapper.updateById(notice); } /** * 删除公告对象 * * @param noticeId 公告ID * @return 结果 */ @Override public int deleteNoticeById(String noticeId) { return baseMapper.deleteById(noticeId); } /** * 批量删除公告信息 * * @param noticeIds 需要删除的公告ID * @return 结果 */ @Override public int deleteNoticeByIds(String[] noticeIds) { return baseMapper.deleteBatchIds(Arrays.asList(noticeIds)); } }