Antiloveg 8 years ago
parent
commit
06e0204496

+ 46 - 2
src/main/java/com/goafanti/activity/bo/ActivityListBo.java

@@ -2,6 +2,12 @@ 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;
 
@@ -79,7 +85,8 @@ public class ActivityListBo {
 	public void setHost(String host) {
 		this.host = host;
 	}
-
+	
+	@JsonFormat(shape = Shape.STRING)
 	public Integer getType() {
 		return type;
 	}
@@ -87,7 +94,8 @@ public class ActivityListBo {
 	public void setType(Integer type) {
 		this.type = type;
 	}
-
+	
+	@JsonFormat(shape = Shape.STRING)
 	public Integer getForm() {
 		return form;
 	}
@@ -104,4 +112,40 @@ public class ActivityListBo {
 		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) {
+
+	}
+
 }

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

@@ -8,4 +8,7 @@ public interface ActivityService {
 	Pagination<Activity> 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);
+
 }

+ 7 - 0
src/main/java/com/goafanti/activity/service/impl/ActivityServiceImpl.java

@@ -61,4 +61,11 @@ public class ActivityServiceImpl extends BaseMybatisDao<ActivityMapper> implemen
 		return (Pagination<Activity>) findPage("findActivityListByPage", "findActivityCount", params, pNo, pSize);
 	}
 
+	@Override
+	public void save(Activity a, String startTimeFormattedDate, String endTimeFormattedDate,
+			String enrollDeadlineFormattedDate) {
+		// TODO Auto-generated method stub
+		
+	}
+
 }

+ 30 - 6
src/main/java/com/goafanti/admin/controller/AdminActivityApiController.java

@@ -3,6 +3,7 @@ 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;
@@ -14,6 +15,7 @@ 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;
 
 /**
@@ -43,26 +45,48 @@ public class AdminActivityApiController extends BaseApiController {
 		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){
+			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())){
+
+		if (StringUtils.isBlank(ia.getName())) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "标题"));
 			return res;
 		}
-		
-		//if(StringUtils.)
+
+		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;
 	}
 }

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

@@ -2,222 +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 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;
-    }
-
-    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 Date getCreateTime() {
-        return createTime;
-    }
-
-    public void setCreateTime(Date createTime) {
-        this.createTime = createTime;
-    }
-
-    public Date getEnrollDeadline() {
-        return enrollDeadline;
-    }
+import org.apache.commons.lang3.time.DateFormatUtils;
 
-    public void setEnrollDeadline(Date enrollDeadline) {
-        this.enrollDeadline = enrollDeadline;
-    }
+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 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 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) {
+
+	}
 }

+ 1 - 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();