Browse Source

news html update

Antiloveg 8 years ago
parent
commit
864fb8ad57

+ 8 - 8
src/main/java/com/goafanti/admin/controller/AdminNewsApiController.java

@@ -2,6 +2,7 @@ package com.goafanti.admin.controller;
 
 import java.text.ParseException;
 import java.util.Arrays;
+import java.util.Calendar;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
@@ -24,7 +25,6 @@ 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;
@@ -134,24 +134,24 @@ 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_TITLE_PICTURE ||
-				attachmentType == AttachmentType.NEWS_CONTENT_PICTURE) {
-			res.setData(handleFiles(res, "/news/", false, req, sign, TokenManager.getAdminId()));
+		if (attachmentType == AttachmentType.NEWS_TITLE_PICTURE
+				|| attachmentType == AttachmentType.NEWS_CONTENT_PICTURE) {
+			Calendar c = Calendar.getInstance();
+			res.setData(handleFile(res, false, req, sign, String.valueOf(c.get(Calendar.YEAR)),
+					String.valueOf(c.get(Calendar.MONTH) + 1), idGenerator.generateId().toString()));
 		} else {
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
 		}
 		return res;
 	}
-	
-	
 
 	private Result disposeInputNews(Result res, InputNews news, String createTimeFormattedDate) {
 		if (StringUtils.isBlank(news.getTitle())) {

+ 2 - 1
src/main/java/com/goafanti/common/dao/NewsMapper.java

@@ -4,6 +4,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.goafanti.common.model.News;
+import com.goafanti.news.bo.NewsPortalList;
 import com.goafanti.news.bo.NewsSummary;
 
 public interface NewsMapper {
@@ -25,6 +26,6 @@ public interface NewsMapper {
 
 	int batchDeleteByPrimaryKey(List<String> id);
 
-	List<NewsSummary> findPortalList(Map<String, Object> params);
+	List<NewsPortalList> findPortalList(Map<String, Object> params);
 
 }

+ 4 - 2
src/main/java/com/goafanti/common/mapper/NewsMapper.xml

@@ -273,7 +273,7 @@
 	</foreach>
   </delete>
   
-  <select id="findPortalList" resultType="com.goafanti.news.bo.NewsSummary">
+  <select id="findPortalList" resultType="com.goafanti.news.bo.NewsPortalList">
 		select
 			id, 
 			create_time as createTime, 
@@ -281,7 +281,9 @@
 			title_img as titleImg, 
 			type, 
 			hot, 
-			summary
+			summary,
+			source,
+			content
 		from news
 		where 1 =1
 		<if test="type != null and type != 0" >

+ 1 - 0
src/main/java/com/goafanti/core/cache/serializer/FastJsonRedisSerializer.java

@@ -20,6 +20,7 @@ public class FastJsonRedisSerializer implements RedisSerializer<Object> {
 		pc.addAccept("com.goafanti.star.bo.BigShotStarListBo");
 		pc.addAccept("com.goafanti.lecture.bo.LectureListBo");
 		pc.addAccept("com.goafanti.lecture.bo.BigShotLectureListBo");
+		pc.addAccept("com.goafanti.news.bo.NewsPortalList");
 	}
 
 	@Override

+ 15 - 7
src/main/java/com/goafanti/news/controller/NewsController.java

@@ -46,19 +46,27 @@ public class NewsController extends BaseController {
 	 * 新闻详情
 	 */
 	@RequestMapping(value = "/portal/news/newsDetails", method = RequestMethod.GET)
-	public ModelAndView portalNewsNewsDetails(HttpServletRequest request, ModelAndView modelview) {
+	public ModelAndView portalNewsNewsDetails(HttpServletRequest request, ModelAndView modelview, String noCache) {
 		modelview.setViewName("/portal/news/newsDetails");
-		//modelview.addObject(attributeValue)
+		if (StringUtils.equals(noCache, "clear")) {
+			newsService.cleanPortalList();
+		}
+		modelview.addObject("complete", newsService.findPortalList(5, 0, NewsType.ALL.getCode()));
+		modelview.addObject("kjkx", newsService.findPortalList(5, 0, NewsType.KJZX.getCode()));
+		modelview.addObject("jtdt", newsService.findPortalList(5, 0, NewsType.JTDT.getCode()));
+		modelview.addObject("zfwl", newsService.findPortalList(5, 0, NewsType.ZFWL.getCode()));
+		modelview.addObject("gjzc", newsService.findPortalList(5, 0, NewsType.GJZC.getCode()));
+		modelview.addObject("dfzc", newsService.findPortalList(5, 0, NewsType.DFZC.getCode()));
 		return modelview;
 	}
-	
+
 	/**
 	 * 新闻列表
 	 */
 	@RequestMapping(value = "/portal/news/list", method = RequestMethod.GET)
 	@ResponseBody
-	public Result portalNewsList(Integer type, String pageSize, String pageNo, String noCache){
-		Result res  = new Result();
+	public Result portalNewsList(Integer type, String pageSize, String pageNo, String noCache) {
+		Result res = new Result();
 		if (StringUtils.equals(noCache, "clear")) {
 			newsService.cleanPortalList();
 		}
@@ -80,13 +88,13 @@ public class NewsController extends BaseController {
 		res.setData(newsService.findPortalList(pSize, pNo, type));
 		return res;
 	}
-	
+
 	/**
 	 * 新闻详情
 	 */
 	@RequestMapping(value = "/portal/news/detail", method = RequestMethod.GET)
 	@ResponseBody
-	public Result portalNewsDetail(Long id){
+	public Result portalNewsDetail(Long id) {
 		Result res = new Result();
 		if (null == id) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "新闻ID"));

+ 3 - 2
src/main/java/com/goafanti/news/service/NewsService.java

@@ -22,6 +22,7 @@ import com.goafanti.common.utils.LoggerUtils;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.news.bo.NewsPortalList;
 import com.goafanti.news.bo.NewsSummary;
 
 @Service
@@ -125,8 +126,8 @@ public class NewsService extends BaseMybatisDao<NewsMapper> {
 		return newsMapper.batchDeleteByPrimaryKey(id);
 	}
 	
-	@Cacheable(value = "NewsPortalListCache", key = "'NewsPortalList:Page:'+#pageNo+'Type:'+#type+'Size:'+#pageSize")
-	public List<NewsSummary> findPortalList(Integer pSize, Integer pNo, Integer type) {
+	//@Cacheable(value = "NewsPortalListCache", key = "'NewsPortalList:Page:'+#pageNo+'Type:'+#type+'Size:'+#pageSize")
+	public List<NewsPortalList> findPortalList(Integer pSize, Integer pNo, Integer type) {
 		Map<String, Object> params = new HashMap<String, Object>();
 		params.put("type", type);
 		

+ 1 - 0
src/main/webapp/WEB-INF/views/common.html

@@ -193,6 +193,7 @@
 			globalConfig.uploadPath =  /*[[${uploadPath}]]*/'';
 			globalConfig.uploadPrivatePath =  /*[[${uploadPrivatePath}]]*/'';
 			globalConfig.avatarHost =  /*[[${avatarHost}]]*/'';
+			globalConfig.avatarUploadHost =  /*[[${avatarUploadHost}]]*/'';
 			globalConfig.csrfToken =  /*[[${csrf}]]*/'';
 			window.userData = {};
 			window.adminData = {};

File diff suppressed because it is too large
+ 126 - 29
src/main/webapp/WEB-INF/views/portal/news/newsDetails.html