SysNoticeServiceImpl.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. package com.dgtly.system.service.impl;
  2. import java.util.List;
  3. import com.dgtly.common.annotation.DataScope;
  4. import com.dgtly.common.utils.StringUtils;
  5. import com.dgtly.common.utils.TranslateUtil;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.stereotype.Service;
  8. import com.dgtly.common.core.text.Convert;
  9. import com.dgtly.system.domain.SysNotice;
  10. import com.dgtly.system.mapper.SysNoticeMapper;
  11. import com.dgtly.system.service.ISysNoticeService;
  12. /**
  13. * 公告 服务层实现
  14. *
  15. * @author ruoyi
  16. * @date 2018-06-25
  17. */
  18. @Service
  19. public class SysNoticeServiceImpl implements ISysNoticeService
  20. {
  21. @Autowired
  22. private SysNoticeMapper noticeMapper;
  23. /**
  24. * 查询公告信息
  25. *
  26. * @param noticeId 公告ID
  27. * @return 公告信息
  28. */
  29. @Override
  30. public SysNotice selectNoticeById(Long noticeId)
  31. {
  32. return noticeMapper.selectNoticeById(noticeId);
  33. }
  34. /**
  35. * 查询公告列表
  36. *
  37. * @param notice 公告信息
  38. * @return 公告集合
  39. */
  40. @Override
  41. public List<SysNotice> selectNoticeList(SysNotice notice)
  42. {
  43. return noticeMapper.selectNoticeList(notice);
  44. }
  45. /**
  46. * 新增公告
  47. *
  48. * @param notice 公告信息
  49. * @return 结果
  50. */
  51. @Override
  52. public int insertNotice(SysNotice notice)
  53. {
  54. //公告标题
  55. String noticeTitle = notice.getNoticeTitle();
  56. if(StringUtils.isNotEmpty(noticeTitle)) {
  57. notice.setNoticeTitleEn(TranslateUtil.getEnTranslateInfo(noticeTitle));
  58. }
  59. //公告概要
  60. String noticeOutline = notice.getNoticeOutline();
  61. if (StringUtils.isNotEmpty(noticeOutline)){
  62. notice.setNoticeOutlineEn(TranslateUtil.getEnTranslateInfo(noticeOutline));
  63. }
  64. //公告内容
  65. String noticeContent = notice.getNoticeContent();
  66. if (StringUtils.isNotEmpty(noticeContent)){
  67. notice.setNoticeContentEn(TranslateUtil.getDesEnTranslateInfo(noticeContent));
  68. }
  69. //图片
  70. String fmzFileUrl = notice.getFmzFileUrl();
  71. if (StringUtils.isNotEmpty(fmzFileUrl)){
  72. notice.setFmzFileUrlEn(fmzFileUrl);
  73. }
  74. return noticeMapper.insertNotice(notice);
  75. }
  76. /**
  77. * 修改公告
  78. *
  79. * @param notice 公告信息
  80. * @return 结果
  81. */
  82. @Override
  83. public int updateNotice(SysNotice notice)
  84. {
  85. //公告标题
  86. String noticeTitle = notice.getNoticeTitle();
  87. if(StringUtils.isNotEmpty(noticeTitle)) {
  88. notice.setNoticeTitleEn(TranslateUtil.getEnTranslateInfo(noticeTitle));
  89. }
  90. //公告概要
  91. String noticeOutline = notice.getNoticeOutline();
  92. if (StringUtils.isNotEmpty(noticeOutline)){
  93. notice.setNoticeOutlineEn(TranslateUtil.getEnTranslateInfo(noticeOutline));
  94. }
  95. //公告内容
  96. String noticeContent = notice.getNoticeContent();
  97. if (StringUtils.isNotEmpty(noticeContent)){
  98. notice.setNoticeContentEn(TranslateUtil.getDesEnTranslateInfo(noticeContent));
  99. }
  100. //图片
  101. String fmzFileUrl = notice.getFmzFileUrl();
  102. if (StringUtils.isNotEmpty(fmzFileUrl)){
  103. notice.setFmzFileUrlEn(fmzFileUrl);
  104. }
  105. return noticeMapper.updateNotice(notice);
  106. }
  107. /**
  108. * 删除公告对象
  109. *
  110. * @param ids 需要删除的数据ID
  111. * @return 结果
  112. */
  113. @Override
  114. public int deleteNoticeByIds(String ids)
  115. {
  116. return noticeMapper.deleteNoticeByIds(Convert.toStrArray(ids));
  117. }
  118. /**
  119. * 根据数据权限查询列表
  120. * @param notice
  121. * @return
  122. */
  123. @DataScope(deptAlias = "sd",userAlias = "su")
  124. @Override
  125. public List<SysNotice> selectNoticeListByRole(SysNotice notice) {
  126. return noticeMapper.selectNoticeListByRole(notice);
  127. }
  128. /**
  129. * @descption: 根据类型查询内容列表前三个
  130. * @param: 类型
  131. * @return: 内容列表三个
  132. * @auther: LiuLingChao
  133. * @date: 2019-11-04 11:40
  134. */
  135. @DataScope(deptAlias = "sd",userAlias = "su")
  136. @Override
  137. public List<SysNotice> selectNoticeTop3ByRole(SysNotice notice) {
  138. return noticeMapper.selectNoticeTop3ByRole(notice);
  139. }
  140. }