package com.dgtly.system.service.impl; import java.util.List; import com.dgtly.common.annotation.DataScope; import com.dgtly.common.utils.StringUtils; import com.dgtly.common.utils.TranslateUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.dgtly.common.core.text.Convert; import com.dgtly.system.domain.SysNotice; import com.dgtly.system.mapper.SysNoticeMapper; import com.dgtly.system.service.ISysNoticeService; /** * 公告 服务层实现 * * @author ruoyi * @date 2018-06-25 */ @Service public class SysNoticeServiceImpl implements ISysNoticeService { @Autowired private SysNoticeMapper noticeMapper; /** * 查询公告信息 * * @param noticeId 公告ID * @return 公告信息 */ @Override public SysNotice selectNoticeById(Long noticeId) { return noticeMapper.selectNoticeById(noticeId); } /** * 查询公告列表 * * @param notice 公告信息 * @return 公告集合 */ @Override public List selectNoticeList(SysNotice notice) { return noticeMapper.selectNoticeList(notice); } /** * 新增公告 * * @param notice 公告信息 * @return 结果 */ @Override public int insertNotice(SysNotice notice) { //公告标题 String noticeTitle = notice.getNoticeTitle(); if(StringUtils.isNotEmpty(noticeTitle)) { notice.setNoticeTitleEn(TranslateUtil.getEnTranslateInfo(noticeTitle)); } //公告概要 String noticeOutline = notice.getNoticeOutline(); if (StringUtils.isNotEmpty(noticeOutline)){ notice.setNoticeOutlineEn(TranslateUtil.getEnTranslateInfo(noticeOutline)); } //公告内容 String noticeContent = notice.getNoticeContent(); if (StringUtils.isNotEmpty(noticeContent)){ notice.setNoticeContentEn(TranslateUtil.getDesEnTranslateInfo(noticeContent)); } //图片 String fmzFileUrl = notice.getFmzFileUrl(); if (StringUtils.isNotEmpty(fmzFileUrl)){ notice.setFmzFileUrlEn(fmzFileUrl); } return noticeMapper.insertNotice(notice); } /** * 修改公告 * * @param notice 公告信息 * @return 结果 */ @Override public int updateNotice(SysNotice notice) { //公告标题 String noticeTitle = notice.getNoticeTitle(); if(StringUtils.isNotEmpty(noticeTitle)) { notice.setNoticeTitleEn(TranslateUtil.getEnTranslateInfo(noticeTitle)); } //公告概要 String noticeOutline = notice.getNoticeOutline(); if (StringUtils.isNotEmpty(noticeOutline)){ notice.setNoticeOutlineEn(TranslateUtil.getEnTranslateInfo(noticeOutline)); } //公告内容 String noticeContent = notice.getNoticeContent(); if (StringUtils.isNotEmpty(noticeContent)){ notice.setNoticeContentEn(TranslateUtil.getDesEnTranslateInfo(noticeContent)); } //图片 String fmzFileUrl = notice.getFmzFileUrl(); if (StringUtils.isNotEmpty(fmzFileUrl)){ notice.setFmzFileUrlEn(fmzFileUrl); } return noticeMapper.updateNotice(notice); } /** * 删除公告对象 * * @param ids 需要删除的数据ID * @return 结果 */ @Override public int deleteNoticeByIds(String ids) { return noticeMapper.deleteNoticeByIds(Convert.toStrArray(ids)); } /** * 根据数据权限查询列表 * @param notice * @return */ @DataScope(deptAlias = "sd",userAlias = "su") @Override public List selectNoticeListByRole(SysNotice notice) { return noticeMapper.selectNoticeListByRole(notice); } /** * @descption: 根据类型查询内容列表前三个 * @param: 类型 * @return: 内容列表三个 * @auther: LiuLingChao * @date: 2019-11-04 11:40 */ @DataScope(deptAlias = "sd",userAlias = "su") @Override public List selectNoticeTop3ByRole(SysNotice notice) { return noticeMapper.selectNoticeTop3ByRole(notice); } }