Bläddra i källkod

修改新闻与政策修改与发布接口

anderx 3 år sedan
förälder
incheckning
fa7adda665

+ 2 - 1
src/main/java/com/goafanti/common/model/Policy.java

@@ -9,6 +9,7 @@ import javax.validation.constraints.Size;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonFormat.Shape;
 import com.goafanti.common.constant.ErrorConstants;
+import org.springframework.format.annotation.DateTimeFormat;
 
 public class Policy {
 
@@ -399,4 +400,4 @@ public class Policy {
 	public void setKeyword(String keyword) {
 		this.keyword = keyword;
 	}
-}
+}

+ 26 - 18
src/main/java/com/goafanti/news/bo/InputNews.java

@@ -9,70 +9,78 @@ import javax.validation.constraints.Size;
 import com.goafanti.common.constant.ErrorConstants;
 
 public class InputNews {
-	
+
 	private Long	id;
-	
+
 	Date releaseDate;
 	Date createTime;
 	@Size(min = 0, max = 45, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
 	private String	title;
-	
+
 	@Size(min = 0, max = 128, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
 	private String	titleImg;
-	
+
 	@Size(min = 0, max = 45, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
 	private String	author;
-	
+
 	@Max(value = 99, message = "{" + ErrorConstants.PARAM_ERROR + "}")
 	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
 	private Integer	type;
-	
+
 	@Max(value = 1, message = "{" + ErrorConstants.PARAM_ERROR + "}")
 	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
 	private Integer	hot;
-	
+
 	@Size(min = 0, max = 45, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
 	private String	source;
-	
+
 	@Size(min = 0, max = 255, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
 	private String	sourceUrl;
-	
+
 	@Size(min = 0, max = 144, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
 	private String	summary;
-	
+
 	@Max(value = 1, message = "{" + ErrorConstants.PARAM_ERROR + "}")
 	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
     private Integer jmrhFlag;
-	
+
 	@Max(value = 34, message = "{" + ErrorConstants.PARAM_ERROR + "}")
 	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
 	private Integer provinceId;
-	
+
 	private String	content;
-	
+
 	/**
 	 * 审核状态
 	 */
 	private Integer auditStatus;
-	
+
 	/**
 	 * 是否发布
 	 */
 	private Integer releaseStatus;
-	
+
 	/**
 	 * 置顶
 	 */
 	private Integer topNumber;
-	
+
 	/**
 	 * 热门
 	 */
 	private Integer hotspot;
 	@Size(min = 0, max = 64, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
 	private String keyword;
-	
-	
+
+	private String releaseDateStr;
+
+	public String getReleaseDateStr() {
+		return releaseDateStr;
+	}
+
+	public void setReleaseDateStr(String releaseDateStr) {
+		this.releaseDateStr = releaseDateStr;
+	}
 
 	public Date getReleaseDate() {
 		return releaseDate;

+ 35 - 26
src/main/java/com/goafanti/news/controller/AdminNewsApiController.java

@@ -47,7 +47,7 @@ public class AdminNewsApiController extends BaseApiController {
 	@Autowired
 	private JDBCIdGenerator	idGenerator;
 
-	
+
 	/**
 	 * 新闻列表
 	 */
@@ -56,7 +56,7 @@ public class AdminNewsApiController extends BaseApiController {
 			String source, Integer hot, String pageSize, String pageNo,String auditStatus,String releaseStatus,String publishPage) {
 		Result res = new Result();
 //		if (null == type) {
-//			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "新闻类型"));  
+//			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "新闻类型"));
 //			return res;
 //		}
 		Integer pNo = 1;
@@ -67,7 +67,7 @@ public class AdminNewsApiController extends BaseApiController {
 		if (StringUtils.isNumeric(pageNo)) {
 			pNo = Integer.parseInt(pageNo);
 		}
-		res.setData(newsService.listNews(type, title, author, startCreateTime, endCreateTime, source, hot, pNo, pSize,auditStatus,releaseStatus,publishPage,null)); 
+		res.setData(newsService.listNews(type, title, author, startCreateTime, endCreateTime, source, hot, pNo, pSize,auditStatus,releaseStatus,publishPage,null));
 		return res;
 	}
 
@@ -86,13 +86,13 @@ public class AdminNewsApiController extends BaseApiController {
 		if (!res.getError().isEmpty()) {
 			return res;
 		}
-		newsService.save(idGenerator.generateId(), (News) res.getData()); 
+		newsService.save(idGenerator.generateId(), (News) res.getData());
 		return res;
 	}
-	
+
 /*
  * 新增
- * 
+ *
  * */
 	@RequestMapping(value="/apply",method=RequestMethod.POST)
 public Result apply(@Valid InputNews news,BindingResult bindingResult,String[] publishPages) {
@@ -100,7 +100,7 @@ public Result apply(@Valid InputNews news,BindingResult bindingResult,String[] p
 		if (bindingResult.hasErrors()) {
 			result.getError().add(
 					buildErrorByMsg(bindingResult.getFieldError()
-							.getDefaultMessage(), NewsFields 
+							.getDefaultMessage(), NewsFields
 							.getFieldDesc(bindingResult.getFieldError()
 									.getField())));
 			return result;
@@ -121,22 +121,22 @@ public Result apply(@Valid InputNews news,BindingResult bindingResult,String[] p
 		if(news.getType()==null)
 		news.setType(0);
 		BeanUtils.copyProperties(news, news2);
-		result.setData(newsService.save( news2,webPages,appPages)); 
+		result.setData(newsService.save( news2,webPages,appPages));
 		return result;
 	}
-	
+
 	/*
 	 * 修改
-	 * 
+	 *
 	 * */
 		@RequestMapping(value="/updateNews",method=RequestMethod.POST)
 	public Result updateNews(@Valid InputNews news,BindingResult bindingResult,String[] publishPages) {
 			Result result=new Result();
-			
+
 			if (bindingResult.hasErrors()) {
 				result.getError().add(
 						buildErrorByMsg(bindingResult.getFieldError()
-								.getDefaultMessage(), NewsFields 
+								.getDefaultMessage(), NewsFields
 								.getFieldDesc(bindingResult.getFieldError()
 										.getField())));
 				return result;
@@ -150,15 +150,24 @@ public Result apply(@Valid InputNews news,BindingResult bindingResult,String[] p
 			}
 			news.setCreateTime(new Date());
 			if(news.getAuditStatus() == 2) {
-				news.setReleaseDate(new Date());
+				if (news.getReleaseDateStr() !=null){
+					try {
+						news.setReleaseDate(DateUtils.parseDate(news.getReleaseDateStr(),AFTConstants.YYYYMMDDHHMMSS));
+					} catch (ParseException e) {
+						e.printStackTrace();
+					}
+				}else {
+					news.setReleaseDate(new Date());
+				}
+
 			}
 			News news2=new News();
 			BeanUtils.copyProperties(news, news2);
-			result.setData(newsService.updateSelectively( news2,webPages,appPages)); 
+			result.setData(newsService.updateSelectively( news2,webPages,appPages));
 			//publishPages
 			return result;
 		}
-	
+
 
 	/*
 	 * 变更发布状态、发布时间
@@ -183,10 +192,10 @@ public Result apply(@Valid InputNews news,BindingResult bindingResult,String[] p
 				}
 				news.setReleaseDate(new Date());}
 			if(auditStatus!=null) {
-				news.setAuditStatus(auditStatus); 
+				news.setAuditStatus(auditStatus);
 			if(auditStatus ==2){
 				news.setReleaseDate(new Date());
-				
+
 				newsService.updateJtCollectSearch(news);
 				newsService.addJtCollectSearch(news);
 				}
@@ -194,13 +203,13 @@ public Result apply(@Valid InputNews news,BindingResult bindingResult,String[] p
 				newsService.updateJtCollectSearch(news);
 				}
 			}
-			
-			result.setData(newsService.updateSelectivelyWithoutPages(news));  
+
+			result.setData(newsService.updateSelectivelyWithoutPages(news));
 			return result;
-			
+
 		}
-		
-		
+
+
 	private void checkApplyParams(InputNews news, List<String>webPages,List<String>appPages, Result result) {
 	/*if(webPages.size()<1 && appPages.size()<1)
 	{
@@ -224,7 +233,7 @@ public Result apply(@Valid InputNews news,BindingResult bindingResult,String[] p
 		result.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","是否热门"));
 		return;
 	}
-	
+
 }
 
 	/**
@@ -262,7 +271,7 @@ public Result apply(@Valid InputNews news,BindingResult bindingResult,String[] p
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "新闻Id"));
 			return res;
 		}
-		res.setData(newsService.findNewsDetail(id));  
+		res.setData(newsService.findNewsDetail(id));
 		return res;
 	}
 
@@ -288,7 +297,7 @@ public Result apply(@Valid InputNews news,BindingResult bindingResult,String[] p
 		if (id == null) {
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
 		} else {
-			res.setData(newsService.deleteByPrimaryKey(id)); 
+			res.setData(newsService.deleteByPrimaryKey(id));
 		}
 		return res;
 	}
@@ -331,7 +340,7 @@ public Result apply(@Valid InputNews news,BindingResult bindingResult,String[] p
 		}
 		return res;
 	}
-	
+
 
 	private Result disposeInputNews(Result res, InputNews news, String createTimeFormattedDate) {
 		if (StringUtils.isBlank(news.getTitle())) {

+ 17 - 3
src/main/java/com/goafanti/news/controller/AdminPolicyApiController.java

@@ -1,5 +1,6 @@
 package com.goafanti.news.controller;
 
+import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -9,9 +10,13 @@ import java.util.Map;
 import javax.annotation.Resource;
 import javax.validation.Valid;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.goafanti.common.constant.AFTConstants;
+import com.goafanti.common.utils.DateUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
@@ -136,7 +141,7 @@ public class AdminPolicyApiController extends BaseApiController {
 		 *
 		 * */
 			@RequestMapping(value="/update",method=RequestMethod.POST)
-		public Result updateNews(@Valid Policy policy,BindingResult bindingResult,String[] publishPages) {
+		public Result updateNews( @Valid Policy policy, BindingResult bindingResult, String[] publishPages, String releaseDateStr) {
 				Result result=new Result();
 				if (bindingResult.hasErrors()) {
 					result.getError().add(
@@ -158,9 +163,18 @@ public class AdminPolicyApiController extends BaseApiController {
 					return result;
 				}
 				if(policy.getAuditStatus()!=null ) {
-					policy.setReleaseDate(new Date());
-					if(policy.getAuditStatus() ==2){
 
+
+					if(policy.getAuditStatus() ==2){
+						if (releaseDateStr !=null){
+							try {
+								policy.setReleaseDate(DateUtils.parseDate(releaseDateStr, AFTConstants.YYYYMMDDHHMMSS));
+							} catch (ParseException e) {
+								e.printStackTrace();
+							}
+						}else {
+							policy.setReleaseDate(new Date());
+						}
 						policyService.addJtCollectSearch(policy);
 						}
 					if(policy.getAuditStatus()==4) {

+ 1 - 1
src/main/resources/props/config_local.properties

@@ -44,7 +44,7 @@ skjt.host=//ss.jishutao.com/skjt/1.3
 
 
 #本地
-static.host=//172.16.0.255:3000/jitao/client/1.2.8
+static.host=//172.16.0.255/client/1.2.8
 portal.host=//172.16.0.255:3000/jitao/portal/1.2.11
 
 #avatar.host=//ss.jishutao.com