|
@@ -6,11 +6,14 @@ import com.ruoyi.common.core.controller.BaseController;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
import com.ruoyi.post.domain.PostBulletin;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import com.ruoyi.post.service.IPostBulletinService;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -64,17 +67,20 @@ public class PostBulletinController extends BaseController
|
|
|
return success(postBulletinService.selectPostBulletinByNoticeId(noticeId));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 新增通知公告;
|
|
|
- */
|
|
|
@PreAuthorize("@ss.hasPermi('system:bulletin:add')")
|
|
|
@Log(title = "新增通知公告; ", businessType = BusinessType.INSERT)
|
|
|
@PostMapping("/add")
|
|
|
- public AjaxResult add(@RequestBody PostBulletin postBulletin)
|
|
|
+ public AjaxResult add(@Validated @RequestBody PostBulletin postBulletin)
|
|
|
{
|
|
|
-// if(UserConstants.NOT_UNIQUE.equals(postBulletinService.newsTitleAndNewsContentIsNull(postBulletin))){
|
|
|
-// return AjaxResult.error("新增失败"+postBulletin.getNoticeTitle()+"消息标题及内容已经存在");
|
|
|
-// }
|
|
|
+ if(UserConstants.NOT_UNIQUE.equals(postBulletinService.checkTitle(postBulletin)))
|
|
|
+ {
|
|
|
+ return AjaxResult.error("新增公告"+postBulletin.getNoticeTitle()+"失败,公告标题已经存在");
|
|
|
+ }
|
|
|
+ else if(UserConstants.NOT_UNIQUE.equals(postBulletinService.checkContent(postBulletin)))
|
|
|
+ {
|
|
|
+ return AjaxResult.error("新增公告"+postBulletin.getNoticeContent()+"失败,公告内容已经存在");
|
|
|
+ }
|
|
|
+ postBulletin.setCreateBy(getUsername());
|
|
|
return toAjax(postBulletinService.insertPostBulletin(postBulletin));
|
|
|
}
|
|
|
|
|
@@ -86,6 +92,17 @@ public class PostBulletinController extends BaseController
|
|
|
@PutMapping("/edit")
|
|
|
public AjaxResult edit(@RequestBody PostBulletin postBulletin)
|
|
|
{
|
|
|
+ //判断用户数据是否存在
|
|
|
+
|
|
|
+ if(UserConstants.NOT_UNIQUE.equals(postBulletinService.checkTitle(postBulletin)))
|
|
|
+ {
|
|
|
+ return AjaxResult.error("修改公告"+postBulletin.getNoticeTitle()+"失败,公告标题已经存在");
|
|
|
+ }
|
|
|
+ else if(StringUtils.isNotEmpty(postBulletin.getNoticeContent())&&UserConstants.NOT_UNIQUE.equals(postBulletinService.checkContent(postBulletin)))
|
|
|
+ {
|
|
|
+ return AjaxResult.error("修改公告"+postBulletin.getNoticeContent()+"失败,公告内容已经存在");
|
|
|
+ }
|
|
|
+ postBulletin.setCreateBy(getUsername());
|
|
|
return toAjax(postBulletinService.updatePostBulletin(postBulletin));
|
|
|
}
|
|
|
|