Commit 4e3cdf4b authored by huangjiamin's avatar huangjiamin

Merge branch 'feature-maintain-notice' into 'master'

Feature maintain notice

See merge request !241
parents 677dd280 20ff8a2f
...@@ -13,6 +13,7 @@ import com.edgec.browserbackend.browser.repository.IpResourceRepository; ...@@ -13,6 +13,7 @@ import com.edgec.browserbackend.browser.repository.IpResourceRepository;
import com.edgec.browserbackend.browser.repository.ProxyConfigRepository; import com.edgec.browserbackend.browser.repository.ProxyConfigRepository;
import com.edgec.browserbackend.browser.repository.ShopRepository; import com.edgec.browserbackend.browser.repository.ShopRepository;
import com.edgec.browserbackend.common.commons.error.ClientRequestException; import com.edgec.browserbackend.common.commons.error.ClientRequestException;
import com.edgec.browserbackend.common.commons.utils.DateConverter;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -773,6 +774,14 @@ public class AdministratorServiceImpl implements AdministratorService { ...@@ -773,6 +774,14 @@ public class AdministratorServiceImpl implements AdministratorService {
@Override @Override
public void setNotice(Notice notice) { public void setNotice(Notice notice) {
if (notice == null
|| StringUtils.isEmpty(notice.getStarDate())
|| StringUtils.isEmpty(notice.getEndDate())
|| StringUtils.isEmpty(notice.getContent())
|| DateConverter.stringToDate(notice.getStarDate()).
compareTo(DateConverter.stringToDate(notice.getEndDate())) > 0) {
throw new ClientRequestException(AccountErrorCode.OTHERS);
}
Notice only = noticeRepository.findOneByNameIsNotNull(); Notice only = noticeRepository.findOneByNameIsNotNull();
if (only != null) { if (only != null) {
only.setStarDate(notice.getStarDate()); only.setStarDate(notice.getStarDate());
...@@ -797,13 +806,4 @@ public class AdministratorServiceImpl implements AdministratorService { ...@@ -797,13 +806,4 @@ public class AdministratorServiceImpl implements AdministratorService {
public void delNotice() { public void delNotice() {
noticeRepository.deleteAll(); noticeRepository.deleteAll();
} }
} }
\ No newline at end of file
package com.edgec.browserbackend.browser.controller; package com.edgec.browserbackend.browser.controller;
import com.edgec.browserbackend.account.dto.NoticeDto;
import com.edgec.browserbackend.account.dto.ResultDto; import com.edgec.browserbackend.account.dto.ResultDto;
import com.edgec.browserbackend.account.service.AdministratorService;
import com.edgec.browserbackend.browser.service.GlobalFieldService; import com.edgec.browserbackend.browser.service.GlobalFieldService;
import com.edgec.browserbackend.common.commons.error.ClientRequestException; import com.edgec.browserbackend.common.commons.error.ClientRequestException;
import com.edgec.browserbackend.common.utils.ResponseUtil; import com.edgec.browserbackend.common.utils.ResponseUtil;
...@@ -9,6 +11,7 @@ import org.slf4j.LoggerFactory; ...@@ -9,6 +11,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -24,6 +27,9 @@ public class GlobalFieldController { ...@@ -24,6 +27,9 @@ public class GlobalFieldController {
@Autowired @Autowired
private GlobalFieldService globalFieldService; private GlobalFieldService globalFieldService;
@Autowired
private AdministratorService administratorService;
@GetMapping("/speciallinestate") @GetMapping("/speciallinestate")
public ResultDto querySpecialLineState() { public ResultDto querySpecialLineState() {
String logs = "【querySpecialLineState】 "; String logs = "【querySpecialLineState】 ";
...@@ -37,4 +43,12 @@ public class GlobalFieldController { ...@@ -37,4 +43,12 @@ public class GlobalFieldController {
return ResponseUtil.error(e.getMessage()); return ResponseUtil.error(e.getMessage());
} }
} }
/**
* 查询公告
*/
@RequestMapping(path = "/getNotice", method = RequestMethod.GET)
public NoticeDto getNotice() {
return administratorService.getNotice();
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment