Przeglądaj źródła

Merge branch 'master' of https://git.coding.net/aft/AFT.git

albertshaw 8 lat temu
rodzic
commit
a5b86e694d

+ 6 - 0
schema/20170719-alter-activity.sql

@@ -0,0 +1,6 @@
+alter table `activity` 
+add  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(报名开始时间)',
+add `enroll_deadline`  datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '报名截止时间';
+
+alter table `activity`  add  `title_url` varchar(255) DEFAULT NULL COMMENT '题图地址';
+alter table `activity` modify column `img_urls` varchar(1000) DEFAULT NULL COMMENT '活动图片地址';

+ 151 - 0
src/main/java/com/goafanti/activity/bo/ActivityListBo.java

@@ -0,0 +1,151 @@
+package com.goafanti.activity.bo;
+
+import java.util.Date;
+
+import org.apache.commons.lang3.time.DateFormatUtils;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonFormat.Shape;
+import com.goafanti.common.constant.AFTConstants;
+
+public class ActivityListBo {
+	private Long	id;
+
+	/**
+	 * 开始时间
+	 */
+	private Date	startTime;
+
+	/**
+	 * 结束时间
+	 */
+	private Date	endTime;
+
+	/**
+	 * 标题
+	 */
+	private String	name;
+
+	/**
+	 * 主办单位
+	 */
+	private String	host;
+
+	/**
+	 * 活动类型
+	 */
+	private Integer	type;
+
+	/**
+	 * 活动形式
+	 */
+	private Integer	form;
+
+	/**
+	 * 报名截止时间
+	 */
+	private Date	enrollDeadline;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Date getStartTime() {
+		return startTime;
+	}
+
+	public void setStartTime(Date startTime) {
+		this.startTime = startTime;
+	}
+
+	public Date getEndTime() {
+		return endTime;
+	}
+
+	public void setEndTime(Date endTime) {
+		this.endTime = endTime;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getHost() {
+		return host;
+	}
+
+	public void setHost(String host) {
+		this.host = host;
+	}
+	
+	@JsonFormat(shape = Shape.STRING)
+	public Integer getType() {
+		return type;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+	
+	@JsonFormat(shape = Shape.STRING)
+	public Integer getForm() {
+		return form;
+	}
+
+	public void setForm(Integer form) {
+		this.form = form;
+	}
+
+	public Date getEnrollDeadline() {
+		return enrollDeadline;
+	}
+
+	public void setEnrollDeadline(Date enrollDeadline) {
+		this.enrollDeadline = enrollDeadline;
+	}
+
+	public String getStartTimeFormattedDate() {
+		if (this.startTime == null) {
+			return null;
+		} else {
+			return DateFormatUtils.format(this.startTime, AFTConstants.YYYYMMDD);
+		}
+	}
+
+	public void setStartTimeFormattedDate(String startTimeFormattedDate) {
+
+	}
+
+	public String getEndTimeFormattedDate() {
+		if (this.endTime == null) {
+			return null;
+		} else {
+			return DateFormatUtils.format(this.endTime, AFTConstants.YYYYMMDD);
+		}
+	}
+
+	public void setEndTimeFormattedDate(String endTimeFormattedDate) {
+
+	}
+
+	public String getEnrollDeadlineFormattedDate() {
+		if (this.enrollDeadline == null) {
+			return null;
+		} else {
+			return DateFormatUtils.format(this.enrollDeadline, AFTConstants.YYYYMMDD);
+		}
+	}
+
+	public void setEnrollDeadlineFormattedDate(String enrollDeadlineFormattedDate) {
+
+	}
+
+}

+ 147 - 0
src/main/java/com/goafanti/activity/bo/InputActivity.java

@@ -0,0 +1,147 @@
+package com.goafanti.activity.bo;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.Size;
+
+import com.goafanti.common.constant.ErrorConstants;
+
+public class InputActivity {
+	@Max(value = 999999999999999999L, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Long	id;
+
+	@Size(min = 0, max = 45, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	name;
+
+	@Size(min = 0, max = 128, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	address;
+
+	@Size(min = 0, max = 45, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	host;
+
+	@Size(min = 0, max = 45, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	undertake;
+
+	@Size(min = 0, max = 255, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	asist;
+
+	@Max(value = 9, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer	type;
+
+	@Max(value = 9, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer	form;
+
+	@Size(min = 0, max = 1000, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	imgUrls;
+
+	@Size(min = 0, max = 255, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	result;
+
+	@Size(min = 0, max = 255, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	titleUrl;
+
+	/**
+	 * 描述
+	 */
+	private String	desc;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getAddress() {
+		return address;
+	}
+
+	public void setAddress(String address) {
+		this.address = address;
+	}
+
+	public String getHost() {
+		return host;
+	}
+
+	public void setHost(String host) {
+		this.host = host;
+	}
+
+	public String getUndertake() {
+		return undertake;
+	}
+
+	public void setUndertake(String undertake) {
+		this.undertake = undertake;
+	}
+
+	public String getAsist() {
+		return asist;
+	}
+
+	public void setAsist(String asist) {
+		this.asist = asist;
+	}
+
+	public Integer getType() {
+		return type;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
+	public Integer getForm() {
+		return form;
+	}
+
+	public void setForm(Integer form) {
+		this.form = form;
+	}
+
+	public String getImgUrls() {
+		return imgUrls;
+	}
+
+	public void setImgUrls(String imgUrls) {
+		this.imgUrls = imgUrls;
+	}
+
+	public String getResult() {
+		return result;
+	}
+
+	public void setResult(String result) {
+		this.result = result;
+	}
+
+	public String getTitleUrl() {
+		return titleUrl;
+	}
+
+	public void setTitleUrl(String titleUrl) {
+		this.titleUrl = titleUrl;
+	}
+
+	public String getDesc() {
+		return desc;
+	}
+
+	public void setDesc(String desc) {
+		this.desc = desc;
+	}
+
+}

+ 10 - 0
src/main/java/com/goafanti/activity/service/ActivityService.java

@@ -1,5 +1,15 @@
 package com.goafanti.activity.service;
 
+import com.goafanti.activity.bo.ActivityListBo;
+import com.goafanti.common.model.Activity;
+import com.goafanti.core.mybatis.page.Pagination;
+
 public interface ActivityService {
 
+	Pagination<ActivityListBo> listActivity(String sTime, String eTime, String name, String host, Integer type, Integer form,
+			Integer pNo, Integer pSize);
+
+	void save(Activity a, String startTimeFormattedDate, String endTimeFormattedDate,
+			String enrollDeadlineFormattedDate);
+
 }

+ 65 - 3
src/main/java/com/goafanti/activity/service/impl/ActivityServiceImpl.java

@@ -1,10 +1,72 @@
 package com.goafanti.activity.service.impl;
 
+import java.text.ParseException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import com.goafanti.activity.bo.ActivityListBo;
 import com.goafanti.activity.service.ActivityService;
+import com.goafanti.common.constant.AFTConstants;
+import com.goafanti.common.dao.ActivityMapper;
+import com.goafanti.common.model.Activity;
+import com.goafanti.common.utils.DateUtils;
+import com.goafanti.core.mybatis.BaseMybatisDao;
+import com.goafanti.core.mybatis.page.Pagination;
+
 @Service
-public class ActivityServiceImpl implements ActivityService {
-	/*@Autowired
-	private ActivityMapper activityMapper;*/
+public class ActivityServiceImpl extends BaseMybatisDao<ActivityMapper> implements ActivityService {
+	@Autowired
+	private ActivityMapper activityMapper;
+
+	@SuppressWarnings("unchecked")
+	@Override
+	public Pagination<ActivityListBo> listActivity(String sTime, String eTime, String name, String host, Integer type,
+			Integer form, Integer pNo, Integer pSize) {
+
+		Map<String, Object> params = new HashMap<>();
+
+		try {
+			params.put("sTime", StringUtils.isBlank(sTime) ? null : DateUtils.parseDate(sTime, AFTConstants.YYYYMMDD));
+			params.put("eTime", StringUtils.isBlank(eTime) ? null
+					: DateUtils.addDays(DateUtils.parseDate(eTime, AFTConstants.YYYYMMDD), 1));
+		} catch (ParseException e) {
+		}
+
+		if (StringUtils.isNotBlank(name)) {
+			params.put("name", name);
+		}
+
+		if (StringUtils.isNotBlank(host)) {
+			params.put("host", host);
+		}
+
+		if (null != type) {
+			params.put("type", type);
+		}
+
+		if (null != form) {
+			params.put("form", form);
+		}
+
+		if (pNo == null || pNo < 0) {
+			pNo = 1;
+		}
+
+		if (pSize == null || pSize < 0 || pSize > 10) {
+			pSize = 10;
+		}
+		return (Pagination<ActivityListBo>) findPage("findActivityListByPage", "findActivityCount", params, pNo, pSize);
+	}
+
+	@Override
+	public void save(Activity a, String startTimeFormattedDate, String endTimeFormattedDate,
+			String enrollDeadlineFormattedDate) {
+		// TODO Auto-generated method stub
+		
+	}
+
 }

+ 62 - 2
src/main/java/com/goafanti/admin/controller/AdminActivityApiController.java

@@ -1,14 +1,22 @@
 package com.goafanti.admin.controller;
 
 import javax.annotation.Resource;
+import javax.validation.Valid;
 
+import org.springframework.beans.BeanUtils;
+import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
+import com.goafanti.activity.bo.InputActivity;
 import com.goafanti.activity.service.ActivityService;
 import com.goafanti.common.bo.Result;
+import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.BaseApiController;
+import com.goafanti.common.enums.ActivityFields;
+import com.goafanti.common.model.Activity;
+import com.goafanti.common.utils.StringUtils;
 
 /**
  * 活动圈
@@ -23,10 +31,62 @@ public class AdminActivityApiController extends BaseApiController {
 	 * 活动列表
 	 */
 	@RequestMapping(value = "/list", method = RequestMethod.GET)
-	public Result list(String sTime, String eTime, String name, Integer status, String host, String undertake,
-			Integer type, Integer form, String pageSize, String pageNo) {
+	public Result list(String sTime, String eTime, String name, String host, Integer type, Integer form,
+			String pageSize, String pageNo) {
 		Result res = new Result();
+		Integer pNo = 1;
+		Integer pSize = 10;
+		if (StringUtils.isNumeric(pageSize)) {
+			pSize = Integer.parseInt(pageSize);
+		}
+		if (StringUtils.isNumeric(pageNo)) {
+			pNo = Integer.parseInt(pageNo);
+		}
+		res.setData(activityService.listActivity(sTime, eTime, name, host, type, form, pNo, pSize));
 		return res;
+	}
+
+	/**
+	 * 新增
+	 */
+	@RequestMapping(value = "/add", method = RequestMethod.POST)
+	public Result add(@Valid InputActivity ia, BindingResult bindingResult, String startTimeFormattedDate,
+			String endTimeFormattedDate, String enrollDeadlineFormattedDate) {
+		Result res = new Result();
+		if (bindingResult.hasErrors()) {
+			res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
+					ActivityFields.getFieldDesc(bindingResult.getFieldError().getField())));
+			return res;
+		}
+
+		if (StringUtils.isBlank(ia.getName())) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "标题"));
+			return res;
+		}
 
+		if (StringUtils.isBlank(startTimeFormattedDate)) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "活动开始时间"));
+			return res;
+		}
+
+		if (null == ia.getType()) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "活动类型"));
+			return res;
+		}
+
+		if (null == ia.getForm()) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "活动形式"));
+			return res;
+		}
+
+		if (StringUtils.isBlank(ia.getAddress())) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "活动地点"));
+			return res;
+		}
+
+		Activity a = new Activity();
+		BeanUtils.copyProperties(ia, a);
+		activityService.save(a, startTimeFormattedDate, endTimeFormattedDate, enrollDeadlineFormattedDate);
+		return res;
 	}
 }

+ 58 - 0
src/main/java/com/goafanti/common/enums/ActivityFields.java

@@ -0,0 +1,58 @@
+package com.goafanti.common.enums;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public enum ActivityFields {
+	ID("id", "活动圈活动ID"),
+	NAME("name", "标题"),
+	ADDRESS("address", "活动地址"),
+	HOST("host", "主办单位"),
+	UNDERTAKE("undertake", "承办单位"),
+	ASIST("asist", "协办单位"),
+	TYPE("type", "活动类型"),
+	FORM("form", "活动形式"),
+	IMGURLS("imgUrls", "活动图片地址"),
+	RESULT("result", "活动结果描述"),
+	TITLEURL("titleUrl", "题图地址"),
+	OTHER("", "未知参数");
+
+	private ActivityFields(String code, String desc) {
+		this.code = code;
+		this.desc = desc;
+	}
+
+	private static Map<String, ActivityFields> status = new HashMap<String, ActivityFields>();
+
+	static {
+		for (ActivityFields value : ActivityFields.values()) {
+			status.put(value.getCode(), value);
+		}
+	}
+
+	public static ActivityFields getField(String code) {
+		if (containsType(code)) {
+			return status.get(code);
+		}
+		return OTHER;
+	}
+
+	public static String getFieldDesc(String code) {
+		return getField(code).getDesc();
+	}
+
+	public static boolean containsType(String code) {
+		return status.containsKey(code);
+	}
+
+	private String	code;
+	private String	desc;
+
+	public String getCode() {
+		return code;
+	}
+
+	public String getDesc() {
+		return desc;
+	}
+}

+ 42 - 4
src/main/java/com/goafanti/common/mapper/ActivityMapper.xml

@@ -15,13 +15,16 @@
     <result column="form" property="form" jdbcType="INTEGER" />
     <result column="img_urls" property="imgUrls" jdbcType="VARCHAR" />
     <result column="result" property="result" jdbcType="VARCHAR" />
+    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
+    <result column="enroll_deadline" property="enrollDeadline" jdbcType="TIMESTAMP" />
+    <result column="title_url" property="titleUrl" jdbcType="VARCHAR" />
   </resultMap>
   <resultMap id="ResultMapWithBLOBs" type="com.goafanti.common.model.Activity" extends="BaseResultMap" >
     <result column="desc" property="desc" jdbcType="LONGVARCHAR" />
   </resultMap>
   <sql id="Base_Column_List" >
     id, start_time, end_time, name, status, address, host, undertake, asist, type, form, 
-    img_urls, result
+    img_urls, result, create_time, enroll_deadline, title_url
   </sql>
   <sql id="Blob_Column_List" >
     desc
@@ -43,12 +46,14 @@
       name, status, address, 
       host, undertake, asist, 
       type, form, img_urls, 
-      result, desc)
+      result, create_time, enroll_deadline, 
+      title_url, desc)
     values (#{id,jdbcType=BIGINT}, #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, 
       #{name,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{address,jdbcType=VARCHAR}, 
       #{host,jdbcType=VARCHAR}, #{undertake,jdbcType=VARCHAR}, #{asist,jdbcType=VARCHAR}, 
       #{type,jdbcType=INTEGER}, #{form,jdbcType=INTEGER}, #{imgUrls,jdbcType=VARCHAR}, 
-      #{result,jdbcType=VARCHAR}, #{desc,jdbcType=LONGVARCHAR})
+      #{result,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{enrollDeadline,jdbcType=TIMESTAMP}, 
+      #{titleUrl,jdbcType=VARCHAR}, #{desc,jdbcType=LONGVARCHAR})
   </insert>
   <insert id="insertSelective" parameterType="com.goafanti.common.model.Activity" >
     insert into activity
@@ -92,6 +97,15 @@
       <if test="result != null" >
         result,
       </if>
+      <if test="createTime != null" >
+        create_time,
+      </if>
+      <if test="enrollDeadline != null" >
+        enroll_deadline,
+      </if>
+      <if test="titleUrl != null" >
+        title_url,
+      </if>
       <if test="desc != null" >
         desc,
       </if>
@@ -136,6 +150,15 @@
       <if test="result != null" >
         #{result,jdbcType=VARCHAR},
       </if>
+      <if test="createTime != null" >
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="enrollDeadline != null" >
+        #{enrollDeadline,jdbcType=TIMESTAMP},
+      </if>
+      <if test="titleUrl != null" >
+        #{titleUrl,jdbcType=VARCHAR},
+      </if>
       <if test="desc != null" >
         #{desc,jdbcType=LONGVARCHAR},
       </if>
@@ -180,6 +203,15 @@
       <if test="result != null" >
         result = #{result,jdbcType=VARCHAR},
       </if>
+      <if test="createTime != null" >
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="enrollDeadline != null" >
+        enroll_deadline = #{enrollDeadline,jdbcType=TIMESTAMP},
+      </if>
+      <if test="titleUrl != null" >
+        title_url = #{titleUrl,jdbcType=VARCHAR},
+      </if>
       <if test="desc != null" >
         desc = #{desc,jdbcType=LONGVARCHAR},
       </if>
@@ -200,6 +232,9 @@
       form = #{form,jdbcType=INTEGER},
       img_urls = #{imgUrls,jdbcType=VARCHAR},
       result = #{result,jdbcType=VARCHAR},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      enroll_deadline = #{enrollDeadline,jdbcType=TIMESTAMP},
+      title_url = #{titleUrl,jdbcType=VARCHAR},
       desc = #{desc,jdbcType=LONGVARCHAR}
     where id = #{id,jdbcType=BIGINT}
   </update>
@@ -216,7 +251,10 @@
       type = #{type,jdbcType=INTEGER},
       form = #{form,jdbcType=INTEGER},
       img_urls = #{imgUrls,jdbcType=VARCHAR},
-      result = #{result,jdbcType=VARCHAR}
+      result = #{result,jdbcType=VARCHAR},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      enroll_deadline = #{enrollDeadline,jdbcType=TIMESTAMP},
+      title_url = #{titleUrl,jdbcType=VARCHAR}
     where id = #{id,jdbcType=BIGINT}
   </update>
 </mapper>

+ 64 - 0
src/main/java/com/goafanti/common/mapper/ActivityMapperExt.xml

@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.goafanti.common.dao.ActivityMapper">
+	<select id="findActivityListByPage" parameterType="String" resultType="com.goafanti.activity.bo.ActivityListBo">
+		select
+			id,
+			start_time as startTime,
+			end_time as endTime, 
+			name,
+			host,
+			type,
+			form,
+			enroll_deadline as enrollDeadline
+		from activity
+		where 1=1
+		<if test="sTime != null">
+			start_time <![CDATA[ >= ]]> #{sTime,jdbcType=TIMESTAMP}
+		</if>
+		<if test="eTime != null">
+			start_time <![CDATA[ < ]]> #{eTime,jdbcType=TIMESTAMP}
+		</if>
+		<if test="name != null">
+			name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
+		</if>
+		<if test="host != null">
+			host like CONCAT('%',#{host,jdbcType=VARCHAR},'%')
+		</if>
+		<if test="type != null">
+			type = #{type,jdbcType=INTEGER}
+		</if>
+		<if test="form != null">
+			form = #{form,jdbcType=INTEGER}
+		</if>
+		order by start_time desc
+		<if test="page_sql!=null">
+			${page_sql}
+		</if>
+	</select>
+	
+	<select id="findActivityCount" parameterType="String" resultType="java.lang.Integer">
+		select
+			count(1)
+		from activity
+		where 1=1
+		<if test="sTime != null">
+			start_time <![CDATA[ >= ]]> #{sTime,jdbcType=TIMESTAMP}
+		</if>
+		<if test="eTime != null">
+			start_time <![CDATA[ < ]]> #{eTime,jdbcType=TIMESTAMP}
+		</if>
+		<if test="name != null">
+			name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
+		</if>
+		<if test="host != null">
+			host like CONCAT('%',#{host,jdbcType=VARCHAR},'%')
+		</if>
+		<if test="type != null">
+			type = #{type,jdbcType=INTEGER}
+		</if>
+		<if test="form != null">
+			form = #{form,jdbcType=INTEGER}
+		</if>
+	</select>
+</mapper>

+ 0 - 95
src/main/java/com/goafanti/common/mapper/NewsMapper.xml

@@ -196,100 +196,5 @@
     where id = #{id,jdbcType=BIGINT}
   </update>
   
-  <select id="findNewsListByPage" parameterType="String" resultMap="BaseResultMap">
-  	select
-  		id,
-  		create_time,
-  		title,
-  		author,
-  		type,
-  		hot,
-  		source,
-  		summary
-  	from news
-  	where 1 =1
-  	<if test="type != null">
-  		and type = #{type,jdbcType=INTEGER}
-  	</if>
-  	<if test="title != null">
-  		and title like CONCAT('%',#{title,jdbcType=VARCHAR},'%')
-  	</if>
-  	<if test="author != null">
-  		and author like CONCAT('%',#{author,jdbcType=VARCHAR},'%')
-  	</if>
-  	<if test="sDate != null">
-  	    and create_time <![CDATA[ >= ]]>  #{sDate,jdbcType=TIMESTAMP}
-  	</if>
-  	<if test="eDate != null">
-  		and create_time <![CDATA[ < ]]>  #{eDate,jdbcType=TIMESTAMP}
-  	</if>
-  	<if test="source != null">
-  		and source like CONCAT('%',#{source,jdbcType=VARCHAR},'%')
-  	</if>
-  	<if test="hot != null">
-  		and hot = #{hot,jdbcType=INTEGER}
-  	</if>
-  	order by create_time desc
-  	<if test="page_sql!=null">
-			${page_sql}
-	</if>
-  </select>
-  
-   <select id="findNewsCount" parameterType="String" resultType="java.lang.Integer">
-  	select
-  		count(1)
-  	from news
-  	where 1 =1
-  	<if test="type != null">
-  		and type = #{type,jdbcType=INTEGER}
-  	</if>
-  	<if test="title != null">
-  		and title like CONCAT('%',#{title,jdbcType=VARCHAR},'%')
-  	</if>
-  	<if test="author != null">
-  		and author like CONCAT('%',#{author,jdbcType=VARCHAR},'%')
-  	</if>
-  	<if test="sDate != null">
-  	    and create_time <![CDATA[ >= ]]>  #{sDate,jdbcType=TIMESTAMP}
-  	</if>
-  	<if test="eDate != null">
-  		and create_time <![CDATA[ < ]]>  #{eDate,jdbcType=TIMESTAMP}
-  	</if>
-  	<if test="source != null">
-  		and source like CONCAT('%',#{source,jdbcType=VARCHAR},'%')
-  	</if>
-  	<if test="hot != null">
-  		and hot = #{hot,jdbcType=INTEGER}
-  	</if>
-  </select>
-  
-  <delete id="batchDeleteByPrimaryKey" parameterType="java.util.List">
-  	delete
-  		from news
-  	where id in
-  	<foreach item="item" index="index" collection="list" open="("
-			separator="," close=")">
-			#{item}
-	</foreach>
-  </delete>
   
-  <select id="findPortalList" resultType="com.goafanti.news.bo.NewsPortalList">
-		select
-			id, 
-			create_time as createTime, 
-			title , 
-			title_img as titleImg, 
-			type, 
-			hot, 
-			summary,
-			source,
-			content
-		from news
-		where 1 =1
-		<if test="type != null and type != 0" >
-			and type = #{type,jdbcType=INTEGER}
-		</if>
-		order by create_time desc
-		limit #{pageNo,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER}
-	</select>
 </mapper>

+ 98 - 1
src/main/java/com/goafanti/common/mapper/NewsMapperExt.xml

@@ -17,11 +17,108 @@
 		select
 		<include refid="Summary_Column_List" />
 		from news
-		where hot = 1 
+		where hot = 0 
 		<if test=" type != null">
 			and type = #{type,jdbcType=INTEGER}
 		</if>
 		order by id desc
 		limit #{pageNo,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER}
 	</select>
+	
+	<select id="findNewsListByPage" parameterType="String" resultMap="BaseResultMap">
+  	select
+  		id,
+  		create_time,
+  		title,
+  		author,
+  		type,
+  		hot,
+  		source,
+  		summary
+  	from news
+  	where 1 =1
+  	<if test="type != null">
+  		and type = #{type,jdbcType=INTEGER}
+  	</if>
+  	<if test="title != null">
+  		and title like CONCAT('%',#{title,jdbcType=VARCHAR},'%')
+  	</if>
+  	<if test="author != null">
+  		and author like CONCAT('%',#{author,jdbcType=VARCHAR},'%')
+  	</if>
+  	<if test="sDate != null">
+  	    and create_time <![CDATA[ >= ]]>  #{sDate,jdbcType=TIMESTAMP}
+  	</if>
+  	<if test="eDate != null">
+  		and create_time <![CDATA[ < ]]>  #{eDate,jdbcType=TIMESTAMP}
+  	</if>
+  	<if test="source != null">
+  		and source like CONCAT('%',#{source,jdbcType=VARCHAR},'%')
+  	</if>
+  	<if test="hot != null">
+  		and hot = #{hot,jdbcType=INTEGER}
+  	</if>
+  	order by create_time desc
+  	<if test="page_sql!=null">
+			${page_sql}
+	</if>
+  </select>
+  
+   <select id="findNewsCount" parameterType="String" resultType="java.lang.Integer">
+  	select
+  		count(1)
+  	from news
+  	where 1 =1
+  	<if test="type != null">
+  		and type = #{type,jdbcType=INTEGER}
+  	</if>
+  	<if test="title != null">
+  		and title like CONCAT('%',#{title,jdbcType=VARCHAR},'%')
+  	</if>
+  	<if test="author != null">
+  		and author like CONCAT('%',#{author,jdbcType=VARCHAR},'%')
+  	</if>
+  	<if test="sDate != null">
+  	    and create_time <![CDATA[ >= ]]>  #{sDate,jdbcType=TIMESTAMP}
+  	</if>
+  	<if test="eDate != null">
+  		and create_time <![CDATA[ < ]]>  #{eDate,jdbcType=TIMESTAMP}
+  	</if>
+  	<if test="source != null">
+  		and source like CONCAT('%',#{source,jdbcType=VARCHAR},'%')
+  	</if>
+  	<if test="hot != null">
+  		and hot = #{hot,jdbcType=INTEGER}
+  	</if>
+  </select>
+  
+  <delete id="batchDeleteByPrimaryKey" parameterType="java.util.List">
+  	delete
+  		from news
+  	where id in
+  	<foreach item="item" index="index" collection="list" open="("
+			separator="," close=")">
+			#{item}
+	</foreach>
+  </delete>
+  
+  <select id="findPortalList" resultType="com.goafanti.news.bo.NewsPortalList">
+		select
+			id, 
+			create_time as createTime, 
+			title , 
+			title_img as titleImg, 
+			type, 
+			hot, 
+			summary,
+			source,
+			content
+		from news
+		where 1 =1
+		<if test="type != null and type != 0" >
+			and type = #{type,jdbcType=INTEGER}
+		</if>
+		order by create_time desc
+		limit #{pageNo,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER}
+	</select>
 </mapper>

+ 262 - 177
src/main/java/com/goafanti/common/model/Activity.java

@@ -2,183 +2,268 @@ package com.goafanti.common.model;
 
 import java.util.Date;
 
-public class Activity {
-    private Long id;
-
-    /**
-    * 开始时间
-    */
-    private Date startTime;
-
-    /**
-    * 结束时间
-    */
-    private Date endTime;
-
-    /**
-    * 标题
-    */
-    private String name;
-
-    /**
-    * 状态
-    */
-    private Integer status;
-
-    /**
-    * 活动地址
-    */
-    private String address;
-
-    /**
-    * 主办单位
-    */
-    private String host;
-
-    /**
-    * 承办单位
-    */
-    private String undertake;
-
-    /**
-    * 协办单位,逗号隔开
-    */
-    private String asist;
-
-    /**
-    * 活动类型
-    */
-    private Integer type;
-
-    /**
-    * 活动形式
-    */
-    private Integer form;
-
-    /**
-    * 活动图片地址
-    */
-    private String imgUrls;
-
-    /**
-    * 活动结果描述
-    */
-    private String result;
-
-    /**
-    * 描述
-    */
-    private String desc;
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public Date getStartTime() {
-        return startTime;
-    }
-
-    public void setStartTime(Date startTime) {
-        this.startTime = startTime;
-    }
-
-    public Date getEndTime() {
-        return endTime;
-    }
-
-    public void setEndTime(Date endTime) {
-        this.endTime = endTime;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public Integer getStatus() {
-        return status;
-    }
-
-    public void setStatus(Integer status) {
-        this.status = status;
-    }
-
-    public String getAddress() {
-        return address;
-    }
-
-    public void setAddress(String address) {
-        this.address = address;
-    }
-
-    public String getHost() {
-        return host;
-    }
-
-    public void setHost(String host) {
-        this.host = host;
-    }
-
-    public String getUndertake() {
-        return undertake;
-    }
-
-    public void setUndertake(String undertake) {
-        this.undertake = undertake;
-    }
-
-    public String getAsist() {
-        return asist;
-    }
-
-    public void setAsist(String asist) {
-        this.asist = asist;
-    }
-
-    public Integer getType() {
-        return type;
-    }
-
-    public void setType(Integer type) {
-        this.type = type;
-    }
-
-    public Integer getForm() {
-        return form;
-    }
-
-    public void setForm(Integer form) {
-        this.form = form;
-    }
-
-    public String getImgUrls() {
-        return imgUrls;
-    }
-
-    public void setImgUrls(String imgUrls) {
-        this.imgUrls = imgUrls;
-    }
-
-    public String getResult() {
-        return result;
-    }
-
-    public void setResult(String result) {
-        this.result = result;
-    }
+import org.apache.commons.lang3.time.DateFormatUtils;
 
-    public String getDesc() {
-        return desc;
-    }
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonFormat.Shape;
+import com.goafanti.common.constant.AFTConstants;
+import com.fasterxml.jackson.annotation.JsonIgnore;
 
-    public void setDesc(String desc) {
-        this.desc = desc;
-    }
+public class Activity {
+	private Long	id;
+
+	/**
+	 * 开始时间
+	 */
+	private Date	startTime;
+
+	/**
+	 * 结束时间
+	 */
+	private Date	endTime;
+
+	/**
+	 * 标题
+	 */
+	private String	name;
+
+	/**
+	 * 状态
+	 */
+	private Integer	status;
+
+	/**
+	 * 活动地址
+	 */
+	private String	address;
+
+	/**
+	 * 主办单位
+	 */
+	private String	host;
+
+	/**
+	 * 承办单位
+	 */
+	private String	undertake;
+
+	/**
+	 * 协办单位,逗号隔开
+	 */
+	private String	asist;
+
+	/**
+	 * 活动类型
+	 */
+	private Integer	type;
+
+	/**
+	 * 活动形式
+	 */
+	private Integer	form;
+
+	/**
+	 * 活动图片地址
+	 */
+	private String	imgUrls;
+
+	/**
+	 * 活动结果描述
+	 */
+	private String	result;
+
+	/**
+	 * 创建时间(报名开始时间)
+	 */
+	private Date	createTime;
+
+	/**
+	 * 报名截止时间
+	 */
+	private Date	enrollDeadline;
+
+	/**
+	 * 题图地址
+	 */
+	private String	titleUrl;
+
+	/**
+	 * 描述
+	 */
+	private String	desc;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Date getStartTime() {
+		return startTime;
+	}
+
+	public void setStartTime(Date startTime) {
+		this.startTime = startTime;
+	}
+
+	public Date getEndTime() {
+		return endTime;
+	}
+
+	public void setEndTime(Date endTime) {
+		this.endTime = endTime;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	public String getAddress() {
+		return address;
+	}
+
+	public void setAddress(String address) {
+		this.address = address;
+	}
+
+	public String getHost() {
+		return host;
+	}
+
+	public void setHost(String host) {
+		this.host = host;
+	}
+
+	public String getUndertake() {
+		return undertake;
+	}
+
+	public void setUndertake(String undertake) {
+		this.undertake = undertake;
+	}
+
+	public String getAsist() {
+		return asist;
+	}
+
+	public void setAsist(String asist) {
+		this.asist = asist;
+	}
+
+	@JsonFormat(shape = Shape.STRING)
+	public Integer getType() {
+		return type;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
+	@JsonFormat(shape = Shape.STRING)
+	public Integer getForm() {
+		return form;
+	}
+
+	public void setForm(Integer form) {
+		this.form = form;
+	}
+
+	public String getImgUrls() {
+		return imgUrls;
+	}
+
+	public void setImgUrls(String imgUrls) {
+		this.imgUrls = imgUrls;
+	}
+
+	public String getResult() {
+		return result;
+	}
+
+	public void setResult(String result) {
+		this.result = result;
+	}
+
+	@JsonIgnore
+	public Date getCreateTime() {
+		return createTime;
+	}
+
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
+	}
+
+	public Date getEnrollDeadline() {
+		return enrollDeadline;
+	}
+
+	public void setEnrollDeadline(Date enrollDeadline) {
+		this.enrollDeadline = enrollDeadline;
+	}
+
+	public String getTitleUrl() {
+		return titleUrl;
+	}
+
+	public void setTitleUrl(String titleUrl) {
+		this.titleUrl = titleUrl;
+	}
+
+	public String getDesc() {
+		return desc;
+	}
+
+	public void setDesc(String desc) {
+		this.desc = desc;
+	}
+
+	public String getStartTimeFormattedDate() {
+		if (this.startTime == null) {
+			return null;
+		} else {
+			return DateFormatUtils.format(this.startTime, AFTConstants.YYYYMMDD);
+		}
+	}
+
+	public void setStartTimeFormattedDate(String startTimeFormattedDate) {
+
+	}
+
+	public String getEndTimeFormattedDate() {
+		if (this.endTime == null) {
+			return null;
+		} else {
+			return DateFormatUtils.format(this.endTime, AFTConstants.YYYYMMDD);
+		}
+	}
+
+	public void setEndTimeFormattedDate(String endTimeFormattedDate) {
+
+	}
+
+	public String getEnrollDeadlineFormattedDate() {
+		if (this.enrollDeadline == null) {
+			return null;
+		} else {
+			return DateFormatUtils.format(this.enrollDeadline, AFTConstants.YYYYMMDD);
+		}
+	}
+
+	public void setEnrollDeadlineFormattedDate(String enrollDeadlineFormattedDate) {
+
+	}
 }

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

@@ -99,7 +99,7 @@ public class NewsController extends BaseController {
 	/**
 	 * 新闻详情
 	 */
-	@RequestMapping(value = "/portal/news/detail", method = RequestMethod.GET)
+	@RequestMapping(value = "/portal/news/detailInfo", method = RequestMethod.GET)
 	@ResponseBody
 	public Result portalNewsDetail(Long id) {
 		Result res = new Result();
@@ -111,6 +111,12 @@ public class NewsController extends BaseController {
 		return res;
 	}
 	
+	@RequestMapping(value = "/portal/news/newsDetail", method = RequestMethod.GET)
+	public ModelAndView portalHighTechEvaluateIprInfo(HttpServletRequest request, ModelAndView modelview) {
+		modelview.setViewName("/portal/news/newsDetail");
+		return modelview;
+	} 
+	
 	private void handleBanners(ModelAndView modelview, BannersType bannersType) {
 		List<Banners> banners = bannersService.findPortalBanners(bannersType.getKey());
 		if (!banners.isEmpty()) {

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

@@ -29,7 +29,7 @@
 			</div>
 			<div class="rt" th:if="${isLogin}">
 				<span>欢迎光临,</span>
-				<a class="login" th:href="${basePath + isAdmin? '/admin/index.html':'/user/account/index.html'}" th:text="${userName}">个人中心</a>
+				<a class="login" th:href="${basePath + (isAdmin? '/admin/index.html':'/user/account/index.html')}" th:text="${userName}">个人中心</a>
 				<a th:href="${basePath + '/user/logout'}">退出</a>
 				<a href="#">导航</a>
 				<a href="#">关于我们</a>

+ 1 - 18
src/main/webapp/WEB-INF/views/portal/news/newsDetail.html

@@ -1,20 +1,3 @@
-<<<<<<< HEAD
-<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml"
-	xmlns:th="http://www.thymeleaf.org">
-<head th:replace="common::header(~{::title},~{::link})">
-	<title>新闻详情</title>
-	<link th:href="${staticHost+'/portal/news/newsDetail.css'}" rel="stylesheet">
-</head>
-<body>
-	<div id="root"></div>
-	
-	<div th:replace="common::footer(~{::script})">
-		<script type="text/javascript" th:src="${staticHost+'/vendors.js'}"></script>
-		<script type="text/javascript" th:src="${staticHost+'/portal/news/newsDetail.css'}"></script>
-	</div>
-</body>
-=======
 <!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
 
@@ -94,5 +77,5 @@
 	</div>
 </body>
 
->>>>>>> branch 'master' of https://git.coding.net/aft/AFT.git
+
 </html>

Plik diff jest za duży
+ 2 - 32
src/main/webapp/WEB-INF/views/portal/news/newsDetails.html


Plik diff jest za duży
+ 5 - 5
src/main/webapp/WEB-INF/views/portal/news/newsIndex.html