|
|
@@ -4,6 +4,7 @@ import java.text.ParseException;
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.validation.Valid;
|
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
@@ -18,10 +19,12 @@ import com.goafanti.common.bo.Result;
|
|
|
import com.goafanti.common.constant.AFTConstants;
|
|
|
import com.goafanti.common.constant.ErrorConstants;
|
|
|
import com.goafanti.common.controller.BaseApiController;
|
|
|
+import com.goafanti.common.enums.AttachmentType;
|
|
|
import com.goafanti.common.model.News;
|
|
|
import com.goafanti.common.utils.DateUtils;
|
|
|
import com.goafanti.common.utils.StringUtils;
|
|
|
import com.goafanti.core.mybatis.JDBCIdGenerator;
|
|
|
+import com.goafanti.core.shiro.token.TokenManager;
|
|
|
import com.goafanti.news.bo.InputNews;
|
|
|
import com.goafanti.news.enums.NewsFields;
|
|
|
import com.goafanti.news.service.NewsService;
|
|
|
@@ -33,7 +36,7 @@ import com.goafanti.news.service.NewsService;
|
|
|
@RequestMapping(value = "/api/admin/news")
|
|
|
public class AdminNewsApiController extends BaseApiController {
|
|
|
@Resource
|
|
|
- private NewsService newsService;
|
|
|
+ private NewsService newsService;
|
|
|
@Autowired
|
|
|
private JDBCIdGenerator idGenerator;
|
|
|
|
|
|
@@ -103,12 +106,12 @@ public class AdminNewsApiController extends BaseApiController {
|
|
|
newsService.update(news.getId(), (News) res.getData());
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 详情
|
|
|
*/
|
|
|
@RequestMapping(value = "/detail", method = RequestMethod.GET)
|
|
|
- public Result detail(Long id){
|
|
|
+ public Result detail(Long id) {
|
|
|
Result res = new Result();
|
|
|
if (null == id) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "新闻Id"));
|
|
|
@@ -117,7 +120,7 @@ public class AdminNewsApiController extends BaseApiController {
|
|
|
res.setData(newsService.findNewsDetail(id));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 删除
|
|
|
*/
|
|
|
@@ -132,6 +135,20 @@ public class AdminNewsApiController extends BaseApiController {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 新闻图片上传
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/upload", method = RequestMethod.POST)
|
|
|
+ public Result upload(HttpServletRequest req, String sign) {
|
|
|
+ Result res = new Result();
|
|
|
+ AttachmentType attachmentType = AttachmentType.getField(sign);
|
|
|
+ if (attachmentType == AttachmentType.NEWS_PIC) {
|
|
|
+ res.setData(handleFiles(res, "/news/", false, req, sign, TokenManager.getAdminId()));
|
|
|
+ } else {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
|
|
|
private Result disposeInputNews(Result res, InputNews news, String createTimeFormattedDate) {
|
|
|
if (StringUtils.isBlank(news.getTitle())) {
|
|
|
@@ -158,5 +175,5 @@ public class AdminNewsApiController extends BaseApiController {
|
|
|
res.setData(n);
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|