Browse Source

客户端--需求列表

Antiloveg 8 years ago
parent
commit
2841036d65

+ 81 - 5
src/main/java/com/goafanti/common/mapper/DemandMapper.xml

@@ -698,7 +698,7 @@
   		d.name, d.keyword, d.info_sources as infoSources,
   		ui.username, d.demand_type as demandType, d.validity_period as validityPeriod,
   		ui.province, d.status, d.release_status as releaseStatus,
-  		d.release_date as releaseDate, a.name as principalId, d.industry_category_a as industryCategoryA,
+  		d.release_date as releaseDate, d.principal_id as principalId, d.industry_category_a as industryCategoryA,
   		d.industry_category_b as industryCategoryB, d.problem_des as problemDes, d.technical_requirements as technicalRequirements,
   		d.picture_url as pictureUrl, d.text_file_url as textFileUrl, d.video_url as videoUrl,
   		d.budget_cost as budgetCost, d.fixed_cycle as fixedCycle, d.people_number as peopleNumber,
@@ -706,7 +706,6 @@
   		info.postal_address as address, u.email as mailbox,  u.mobile as mobile
   	from demand d 
   	left join user_identity ui on ui.uid = d.employer_id
-  	left join admin a on a.id = d.principal_id
   	left join user_info info on info.uid = d.employer_id
   	left join user u on u.id = d.employer_id
   	where d.data_category = 0 and d.id = #{id,jdbcType=VARCHAR}
@@ -719,15 +718,14 @@
   		d.name, d.keyword, d.info_sources as infoSources,
   		oi.unit_name as username, d.demand_type as demandType, d.validity_period as validityPeriod,
   		oi.licence_province as province, d.status, d.release_status as releaseStatus,
-  		d.release_date as releaseDate, a.name as principalId, d.industry_category_a as industryCategoryA,
+  		d.release_date as releaseDate, d.principal_id as principalId, d.industry_category_a as industryCategoryA,
   		d.industry_category_b as industryCategoryB, d.problem_des as problemDes, d.technical_requirements as technicalRequirements,
   		d.picture_url as pictureUrl, d.text_file_url as textFileUrl, d.video_url as videoUrl,
   		d.budget_cost as budgetCost, d.fixed_cycle as fixedCycle, d.people_number as peopleNumber,
   		d.fixed_scheme as fixedScheme, d.cost_escrow as costEscrow, d.employer_id as employerId,
-  		oi.postal_address as address, u.email as mailbox,  oi.contacts 
+  		oi.postal_address as address, u.email as mailbox,  d.contacts 
   	from demand d 
   	left join organization_identity oi on oi.uid = d.employer_id
-  	left join admin a on a.id = d.principal_id
   	left join user u on u.id = d.employer_id
   	where d.data_category = 1 and d.id = #{id,jdbcType=VARCHAR}
   </select>
@@ -745,4 +743,82 @@
   	where id = #{id,jdbcType=VARCHAR}
   </update>
   
+  <select id="findDemandListByPage" parameterType="String" resultType="com.goafanti.demand.bo.DemandListBo">
+  		select 
+	  d.id, d.serial_number as serialNumber, d.data_category as dataCategory, 
+	  d.name, d.keyword, d.demand_type as demandType, 
+	  d.validity_period as validityPeriod, d.status, d.release_status as releaseStatus, 
+	  d.release_date as releaseDate, d.employer_id as employerId
+	from  demand d 
+	where d.deleted_sign = 0 
+	and d.employer_id = #{employerId, jdbcType=VARCHAR}
+	<if test="serialNumber != null">
+		and  d.serial_number = #{serialNumber,jdbcType=INTEGER}
+	</if>
+	<if test="name != null">
+		and  d.name = #{name,jdbcType=VARCHAR}
+	</if>
+	<if test="keyword != null">
+		and  d.keyword like "%"#{keyword,jdbcType=VARCHAR}"%"
+	</if>
+	<if test="demandType != null">
+		and  d.demand_type = #{demandType,jdbcType=INTEGER}
+	</if>
+	<if test="status != null">
+		and  d.status = #{status,jdbcType=VARCHAR}
+	</if>
+	<if test="releaseStatus != null">
+		and  d.release_status = #{releaseStatus,jdbcType=VARCHAR}
+	</if>
+	<if test="vStart != null">
+	   and d.validity_veriod <![CDATA[ > ]]> #{vStart,jdbcType=TIMESTAMP}
+	</if>
+	<if test="vEnd != null">
+	   and d.validity_veriod <![CDATA[ < ]]> #{vEnd,jdbcType=TIMESTAMP}
+	</if>
+	<if test="rStart != null">
+       and	d.release_date <![CDATA[ > ]]> #{rStart,jdbcType=TIMESTAMP}
+	</if>
+	<if test="rEnd != null">
+	   and d.release_date <![CDATA[ < ]]> #{rEnd,jdbcType=TIMESTAMP}
+	</if>
+  	order by d.serial_number desc
+  </select>
+  
+  <select id="findDemandCount" parameterType="String" resultType="java.lang.Integer">
+  		select count(1)
+	from  demand d 
+	where d.deleted_sign = 0 and d.data_category = 1 
+	<if test="serialNumber != null">
+		and  d.serial_number = #{serialNumber,jdbcType=INTEGER}
+	</if>
+	<if test="name != null">
+		and  d.name = #{name,jdbcType=VARCHAR}
+	</if>
+	<if test="keyword != null">
+		and  d.keyword like "%"#{keyword,jdbcType=VARCHAR}"%"
+	</if>
+	<if test="demandType != null">
+		and  d.demand_type = #{demandType,jdbcType=INTEGER}
+	</if>
+	<if test="status != null">
+		and  d.status = #{status,jdbcType=VARCHAR}
+	</if>
+	<if test="releaseStatus != null">
+		and  d.release_status = #{releaseStatus,jdbcType=VARCHAR}
+	</if>
+	<if test="vStart != null">
+	   and d.validity_veriod <![CDATA[ > ]]> #{vStart,jdbcType=TIMESTAMP}
+	</if>
+	<if test="vEnd != null">
+	   and d.validity_veriod <![CDATA[ < ]]> #{vEnd,jdbcType=TIMESTAMP}
+	</if>
+	<if test="rStart != null">
+       and	d.release_date <![CDATA[ > ]]> #{rStart,jdbcType=TIMESTAMP}
+	</if>
+	<if test="rEnd != null">
+	   and d.release_date <![CDATA[ < ]]> #{rEnd,jdbcType=TIMESTAMP}
+	</if>
+  </select>
+  
 </mapper>

+ 173 - 0
src/main/java/com/goafanti/demand/bo/DemandListBo.java

@@ -0,0 +1,173 @@
+package com.goafanti.demand.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 DemandListBo {
+	
+	private String	id;
+
+	/**
+	 * 编号
+	 */
+	private Integer	serialNumber;
+
+	/**
+	 * 数据类别(0-个人需求,1-单位需求)
+	 */
+	private Integer	dataCategory;
+
+	/**
+	 * 名称
+	 */
+	private String	name;
+
+	/**
+	 * 关键词
+	 */
+	private String	keyword;
+	
+	/**
+	 * 发布时间
+	 */
+	private Date	releaseDate;
+	
+	/**
+	 * 需求类型
+	 */
+	private Integer	demandType;
+
+	private Date	validityPeriod;
+	
+	private Integer	status;
+
+	/**
+	 * 是否发布(0-未发布,1-发布)
+	 */
+	private Integer	releaseStatus;
+	
+	private String employerId;
+	
+	public String getEmployerId() {
+		return employerId;
+	}
+
+	public void setEmployerId(String employerId) {
+		this.employerId = employerId;
+	}
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public Integer getSerialNumber() {
+		return serialNumber;
+	}
+
+	public void setSerialNumber(Integer serialNumber) {
+		this.serialNumber = serialNumber;
+	}
+
+	public Integer getDataCategory() {
+		return dataCategory;
+	}
+
+	public void setDataCategory(Integer dataCategory) {
+		this.dataCategory = dataCategory;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getKeyword() {
+		return keyword;
+	}
+
+	public void setKeyword(String keyword) {
+		this.keyword = keyword;
+	}
+	
+	@JsonFormat(shape = Shape.STRING)
+	public Integer getDemandType() {
+		return demandType;
+	}
+
+	public void setDemandType(Integer demandType) {
+		this.demandType = demandType;
+	}
+
+	public Date getValidityPeriod() {
+		return validityPeriod;
+	}
+
+	public void setValidityPeriod(Date validityPeriod) {
+		this.validityPeriod = validityPeriod;
+	}
+	
+	@JsonFormat(shape = Shape.STRING)
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	@JsonFormat(shape = Shape.STRING)
+	public Integer getReleaseStatus() {
+		return releaseStatus;
+	}
+
+	public void setReleaseStatus(Integer releaseStatus) {
+		this.releaseStatus = releaseStatus;
+	}
+
+	public Date getReleaseDate() {
+		return releaseDate;
+	}
+
+	public void setReleaseDate(Date releaseDate) {
+		this.releaseDate = releaseDate;
+	}
+	
+	public String getValidityPeriodFormattedDate() {
+		if (this.validityPeriod == null) {
+			return null;
+		} else {
+			return DateFormatUtils.format(this.getValidityPeriod(), AFTConstants.YYYYMMDDHHMMSS);
+		}
+	}
+
+	public void setValidityPeriodFormattedDate(String validityPeriodFormattedDate) {
+
+	}
+
+	public String getReleaseDateFormattedDate() {
+		if (this.releaseDate == null) {
+			return null;
+		} else {
+			return DateFormatUtils.format(this.getReleaseDate(), AFTConstants.YYYYMMDDHHMMSS);
+		}
+	}
+
+	public void setReleaseDateFormattedDate(String releaseDateFormattedDate) {
+
+	}
+
+
+
+}

+ 13 - 2
src/main/java/com/goafanti/demand/bo/DemandManageDetailBo.java

@@ -2,6 +2,8 @@ package com.goafanti.demand.bo;
 
 import java.math.BigDecimal;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonFormat.Shape;
 
 public class DemandManageDetailBo extends DemandManageListBo {
 
@@ -39,6 +41,17 @@ public class DemandManageDetailBo extends DemandManageListBo {
 
 	private String		mailbox;
 
+	private Integer		contacts;
+	
+	
+	@JsonFormat(shape = Shape.STRING)
+	public Integer getContacts() {
+		return contacts;
+	}
+
+	public void setContacts(Integer contacts) {
+		this.contacts = contacts;
+	}
 
 	public Integer getIndustryCategoryA() {
 		return industryCategoryA;
@@ -175,7 +188,5 @@ public class DemandManageDetailBo extends DemandManageListBo {
 	public void setMailbox(String mailbox) {
 		this.mailbox = mailbox;
 	}
-	
-	
 
 }

+ 1 - 162
src/main/java/com/goafanti/demand/bo/DemandManageListBo.java

@@ -1,36 +1,11 @@
 package com.goafanti.demand.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 DemandManageListBo {
-
-	private String	id;
-
-	/**
-	 * 编号
-	 */
-	private Integer	serialNumber;
-
-	/**
-	 * 数据类别(0-个人需求,1-单位需求)
-	 */
-	private Integer	dataCategory;
-
-	/**
-	 * 名称
-	 */
-	private String	name;
-
-	/**
-	 * 关键词
-	 */
-	private String	keyword;
+public class DemandManageListBo extends DemandListBo{
 
 	/**
 	 * 信息来源(0-平台采集,1-客户发布)
@@ -39,83 +14,14 @@ public class DemandManageListBo {
 
 	private String	username;
 
-	/**
-	 * 需求类型
-	 */
-	private Integer	demandType;
-
-	private Date	validityPeriod;
-
 	private String	employerName;
 
 	private String	province;
 
-	private Integer	status;
-
-	/**
-	 * 是否发布(0-未发布,1-发布)
-	 */
-	private Integer	releaseStatus;
-
-	/**
-	 * 发布时间
-	 */
-	private Date	releaseDate;
-
 	/**
 	 * 负责人(营销员)
 	 */
 	private String	principalId;
-	
-	private String employerId;
-	
-	public String getEmployerId() {
-		return employerId;
-	}
-
-	public void setEmployerId(String employerId) {
-		this.employerId = employerId;
-	}
-
-	public String getId() {
-		return id;
-	}
-
-	public void setId(String id) {
-		this.id = id;
-	}
-
-	public Integer getSerialNumber() {
-		return serialNumber;
-	}
-
-	public void setSerialNumber(Integer serialNumber) {
-		this.serialNumber = serialNumber;
-	}
-
-	public Integer getDataCategory() {
-		return dataCategory;
-	}
-
-	public void setDataCategory(Integer dataCategory) {
-		this.dataCategory = dataCategory;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public String getKeyword() {
-		return keyword;
-	}
-
-	public void setKeyword(String keyword) {
-		this.keyword = keyword;
-	}
 
 	@JsonFormat(shape = Shape.STRING)
 	public Integer getInfoSources() {
@@ -134,23 +40,6 @@ public class DemandManageListBo {
 		this.username = username;
 	}
 
-	@JsonFormat(shape = Shape.STRING)
-	public Integer getDemandType() {
-		return demandType;
-	}
-
-	public void setDemandType(Integer demandType) {
-		this.demandType = demandType;
-	}
-
-	public Date getValidityPeriod() {
-		return validityPeriod;
-	}
-
-	public void setValidityPeriod(Date validityPeriod) {
-		this.validityPeriod = validityPeriod;
-	}
-
 	public String getEmployerName() {
 		return employerName;
 	}
@@ -167,32 +56,6 @@ public class DemandManageListBo {
 		this.province = province;
 	}
 
-	@JsonFormat(shape = Shape.STRING)
-	public Integer getStatus() {
-		return status;
-	}
-
-	public void setStatus(Integer status) {
-		this.status = status;
-	}
-
-	@JsonFormat(shape = Shape.STRING)
-	public Integer getReleaseStatus() {
-		return releaseStatus;
-	}
-
-	public void setReleaseStatus(Integer releaseStatus) {
-		this.releaseStatus = releaseStatus;
-	}
-
-	public Date getReleaseDate() {
-		return releaseDate;
-	}
-
-	public void setReleaseDate(Date releaseDate) {
-		this.releaseDate = releaseDate;
-	}
-
 	public String getPrincipalId() {
 		return principalId;
 	}
@@ -201,28 +64,4 @@ public class DemandManageListBo {
 		this.principalId = principalId;
 	}
 
-	public String getValidityPeriodFormattedDate() {
-		if (this.validityPeriod == null) {
-			return null;
-		} else {
-			return DateFormatUtils.format(this.getValidityPeriod(), AFTConstants.YYYYMMDDHHMMSS);
-		}
-	}
-
-	public void setValidityPeriodFormattedDate(String validityPeriodFormattedDate) {
-
-	}
-
-	public String getReleaseDateFormattedDate() {
-		if (this.releaseDate == null) {
-			return null;
-		} else {
-			return DateFormatUtils.format(this.getReleaseDate(), AFTConstants.YYYYMMDDHHMMSS);
-		}
-	}
-
-	public void setReleaseDateFormattedDate(String releaseDateFormattedDate) {
-
-	}
-
 }

+ 41 - 0
src/main/java/com/goafanti/demand/controller/DemandApiController.java

@@ -0,0 +1,41 @@
+package com.goafanti.demand.controller;
+
+import javax.annotation.Resource;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.goafanti.common.bo.Result;
+import com.goafanti.common.utils.StringUtils;
+import com.goafanti.demand.service.DemandService;
+
+@RestController
+@RequestMapping(value = "/api/user/demand")
+public class DemandApiController {
+	@Resource
+	private DemandService demandService;
+	
+	/**
+	 * 用户需求列表
+	 */
+	public Result list(Integer serialNumber, String name, String keyword, Integer demandType,
+			String validityPeriodStartDate, String validityPeriodEndDate, String username, Integer status,
+			Integer releaseStatus, String releaseDateStartDate, String releaseDateEndDate, String pageNo,
+			String pageSize) {
+		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(demandService.listDemand(serialNumber, name, keyword, demandType,
+				validityPeriodStartDate, validityPeriodEndDate, username, status, releaseStatus, releaseDateStartDate,
+				releaseDateEndDate, pNo, pSize));
+		return res;
+	}
+
+}

+ 6 - 0
src/main/java/com/goafanti/demand/service/DemandService.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.goafanti.common.model.Demand;
 import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.demand.bo.DemandListBo;
 import com.goafanti.demand.bo.DemandManageDetailBo;
 import com.goafanti.demand.bo.DemandManageListBo;
 
@@ -31,4 +32,9 @@ public interface DemandService {
 
 	Demand selectByPrimaryKey(String id);
 
+
+	Pagination<DemandListBo> listDemand(Integer serialNumber, String name, String keyword, Integer demandType,
+			String validityPeriodStartDate, String validityPeriodEndDate, String username, Integer status,
+			Integer releaseStatus, String releaseDateStartDate, String releaseDateEndDate, Integer pNo, Integer pSize);
+
 }

+ 97 - 0
src/main/java/com/goafanti/demand/service/impl/DemandServiceImpl.java

@@ -22,6 +22,7 @@ import com.goafanti.common.utils.DateUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.demand.bo.DemandListBo;
 import com.goafanti.demand.bo.DemandManageDetailBo;
 import com.goafanti.demand.bo.DemandManageListBo;
 import com.goafanti.demand.service.DemandService;
@@ -333,4 +334,100 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 	public Demand selectByPrimaryKey(String id) {
 		return demandMapper.selectByPrimaryKey(id);
 	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	public Pagination<DemandListBo> listDemand(Integer serialNumber, String name, String keyword, Integer demandType,
+			String validityPeriodStartDate, String validityPeriodEndDate, String username, Integer status,
+			Integer releaseStatus, String releaseDateStartDate, String releaseDateEndDate, Integer pNo, Integer pSize) {
+		Map<String, Object> params = new HashMap<>();
+		Date vStart = null;
+		Date vEnd = null;
+		Date rStart = null;
+		Date rEnd = null;
+		
+		params.put("employerId", TokenManager.getUserId());
+
+		if (!StringUtils.isBlank(validityPeriodStartDate)) {
+			try {
+				vStart = DateUtils.parseDate(validityPeriodStartDate, AFTConstants.YYYYMMDD);
+			} catch (ParseException e) {
+			}
+		}
+
+		if (!StringUtils.isBlank(validityPeriodEndDate)) {
+			try {
+				vEnd = DateUtils.parseDate(validityPeriodEndDate, AFTConstants.YYYYMMDD);
+			} catch (ParseException e) {
+			}
+		}
+
+		if (!StringUtils.isBlank(releaseDateStartDate)) {
+			try {
+				rStart = DateUtils.parseDate(releaseDateStartDate, AFTConstants.YYYYMMDD);
+			} catch (ParseException e) {
+			}
+		}
+
+		if (!StringUtils.isBlank(releaseDateEndDate)) {
+			try {
+				rEnd = DateUtils.parseDate(releaseDateEndDate, AFTConstants.YYYYMMDD);
+			} catch (ParseException e) {
+			}
+		}
+
+		if (null != vStart) {
+			params.put("vStart", vStart);
+		}
+
+		if (null != vEnd) {
+			params.put("vEnd", vEnd);
+		}
+
+		if (null != rStart) {
+			params.put("rStart", rStart);
+		}
+
+		if (null != rEnd) {
+			params.put("rEnd", rEnd);
+		}
+
+		if (null != serialNumber) {
+			params.put("serialNumber", serialNumber);
+		}
+
+		if (!StringUtils.isBlank(name)) {
+			params.put("name", name);
+		}
+
+		if (!StringUtils.isBlank(keyword)) {
+			params.put("keyword", keyword);
+		}
+
+		if (!StringUtils.isBlank(username)) {
+			params.put("username", username);
+		}
+
+		if (null != demandType) {
+			params.put("demandType", demandType);
+		}
+
+		if (null != status) {
+			params.put("status", status);
+		}
+
+		if (null != releaseStatus) {
+			params.put("releaseStatus", releaseStatus);
+		}
+
+		if (pNo == null || pNo < 0) {
+			pNo = 1;
+		}
+
+		if (pSize == null || pSize < 0) {
+			pSize = 10;
+		}
+		return  (Pagination<DemandListBo>) findPage("findDemandListByPage", "findDemandCount",
+				params, pNo, pSize);
+	}
 }