Просмотр исходного кода

App成果、需求发布接口增加

anderx лет назад: 8
Родитель
Сommit
caaed55962

+ 2 - 0
src/main/java/com/goafanti/achievement/service/AchievementService.java

@@ -94,6 +94,8 @@ public interface AchievementService {
 
 	AchievementUserOwnerDetailBo selectAppUserOwnerDetail(String id);
 
+	void saveAppAchievement(Achievement a, String[] keywords);
+
 	
 	
 }

+ 33 - 0
src/main/java/com/goafanti/achievement/service/impl/AchievementServiceImpl.java

@@ -772,4 +772,37 @@ public class AchievementServiceImpl extends BaseMybatisDao<AchievementMapper> im
 				params,pNo, pSize);
 	}
 
+	@Override
+	public void saveAppAchievement(Achievement a, String[] keywords) {
+		a.setId(UUID.randomUUID().toString());
+		a.setDeletedSign(DeleteStatus.UNDELETE.getCode());
+		Calendar now = Calendar.getInstance();
+		now.set(Calendar.MILLISECOND, 0);
+		if (TokenManager.getToken() instanceof Admin) {
+			a.setTechBrokerId(TokenManager.getAdminId());
+		}
+		a.setReleaseStatus(AchievementReleaseStatus.UNRELEASE.getCode());
+
+		if (AchievementAuditStatus.SUBMIT.getCode().equals(a.getAuditStatus())) {
+			a.setAuditStatus(DemandAuditStatus.INAUDIT.getCode());
+			createAuditorNotice(a);
+		} else {
+			a.setAuditStatus(AchievementAuditStatus.CREATE.getCode());
+		}
+		if (null!=TokenManager.getUserId()) {
+			a.setOwnerId(TokenManager.getUserId());
+			User u=userMapper.selectByPrimaryKey(TokenManager.getUserId());
+			if (null!=u.getType()) {
+				a.setOwnerType(u.getType());
+			}if (StringUtils.isNotBlank(u.getMobile())) {
+				a.setOwnerMobile(u.getMobile());
+			}if (StringUtils.isNotBlank(u.getNickname())) {
+				a.setOwnerName(u.getNickname());
+			}
+		}
+		a.setCreateTime(now.getTime());
+		achievementMapper.insert(a);
+		disposeAchievementKeyword(keywords, a, false);
+	}
+
 }

+ 87 - 4
src/main/java/com/goafanti/app/controller/AppUserController.java

@@ -17,9 +17,7 @@ import org.springframework.http.HttpMethod;
 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.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
-
 import com.alibaba.fastjson.JSONObject;
 import com.goafanti.achievement.bo.InputAchievement;
 import com.goafanti.achievement.service.AchievementInterestService;
@@ -32,7 +30,10 @@ import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.BaseApiController;
 import com.goafanti.common.enums.AchievementFields;
 import com.goafanti.common.enums.AttachmentType;
+import com.goafanti.common.enums.DemandDataCategory;
+import com.goafanti.common.enums.DemandFields;
 import com.goafanti.common.model.Achievement;
+import com.goafanti.common.model.Demand;
 import com.goafanti.common.model.JpushEasemobAccount;
 import com.goafanti.common.model.MessageConsumer;
 import com.goafanti.common.model.MessageFromSystem;
@@ -41,6 +42,7 @@ import com.goafanti.common.model.User;
 import com.goafanti.common.service.FieldGlossoryService;
 import com.goafanti.common.utils.DateUtils;
 import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.demand.bo.InputDemand;
 import com.goafanti.demand.service.DemandService;
 import com.goafanti.easemob.EasemobUtils;
 import com.goafanti.easemob.bo.EasemobInfo;
@@ -405,7 +407,7 @@ public class AppUserController extends BaseApiController {
         }
         Achievement a = new Achievement();
         BeanUtils.copyProperties(ia, a);
-        achievementService.saveAchievement(a, keywords);
+        achievementService.saveAppAchievement(a, keywords);
         return res;
     }
     
@@ -439,8 +441,89 @@ public class AppUserController extends BaseApiController {
         }
         return res;
     }
+    
+    /**
+	 * 新增需求
+	 */
+	@RequestMapping(value = "/appAddDemand", method = RequestMethod.POST)
+	public Result userApply(@Valid InputDemand demand, BindingResult bindingResult,
+			String keyword1,String keyword2,String keyword3,
+			String validityPeriodFormattedDate) {
+		Result res = new Result();
+		 String[] keywords ;
+	        if (null==keyword3) {
+	        	keywords=new String[]{keyword1,keyword2}; 
+	        }else if (null==keyword2) {
+	        	keywords=new String[]{keyword1};
+	        }else {
+	        	keywords=new String[]{keyword1,keyword2,keyword3};
+			}
+	        demand.setKeyword(StringUtils.join(keywords,","));
+		if (bindingResult.hasErrors()) {
+			res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
+					DemandFields.getFieldDesc(bindingResult.getFieldError().getField())));
+			return res;
+		}
+		res = disposeDemand(res, demand, keywords);
+		if (!res.getError().isEmpty()) {
+			return res;
+		}
+		Demand d = new Demand();
+		BeanUtils.copyProperties(demand, d);
+		if (StringUtils.isNotBlank(demand.getUrgentDays())) {
+			d.setUrgentDays(demand.getUrgentDays());
+		}
+		if (StringUtils.isNotBlank(demand.getUrgentMoney())) {
+			d.setUrgentMoney(demand.getUrgentMoney());
+		}
+		demandService.saveAppUserDemand(d, validityPeriodFormattedDate, keywords);
+		return res;
+	}
+	
+	private Result disposeDemand(Result res, InputDemand demand, String[] keywords) {
+		if (StringUtils.isBlank(demand.getName())) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求名称", "需求名称"));
+			return res;
+		}
+
+		if (StringUtils.isBlank(demand.getKeyword())) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到关键词", "关键词"));
+			return res;
+		}
+
+		if (null == keywords || keywords.length < 1) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到关键词", "关键词"));
+			return res;
+		}
+
+		if (null == demand.getIndustryCategoryA()) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到行业类别", "行业类别"));
+			return res;
+		}
+
+		if (null == demand.getDemandType()) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求类型", "需求类型"));
+			return res;
+		}
+
+		if (StringUtils.isBlank(demand.getProblemDes())) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到问题说明", "问题说明"));
+			return res;
+		}
+
+		for (int i = 0; i < keywords.length; i++) {
+			if (AFTConstants.KEYWORDLENTH < keywords[i].length()) {
+				res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "关键词长度"));
+				return res;
+			}
+		}
+
+		return res;
+	}
+    
+    
     /**
-     * 图片上传
+     * 成果、需求图片上传
      */
     @RequestMapping(value = "/uploadPicture", method = RequestMethod.POST)
     public Result uploadPicture(HttpServletRequest req, String sign) {

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

@@ -94,5 +94,7 @@ public interface DemandService {
 
 	Pagination<DemandSearchListBo> listMyDemand(Integer pNo, Integer pSize);
 
+	void saveAppUserDemand(Demand d, String validityPeriodFormattedDate, String[] keywords);
+
 	
 }

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

@@ -945,6 +945,55 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 		return (Pagination<DemandSearchListBo>) findPage("findAppMyDemandListByPage", "findAppMyDemandCount", params, pNo, pSize);
 	}
 
+	public void saveAppUserDemand(Demand d, String validityPeriodFormattedDate, String[] keywords) {
+		Date validityPeriod = null;
+		if (!StringUtils.isBlank(validityPeriodFormattedDate)) {
+			try {
+				validityPeriod = DateUtils.parseDate(validityPeriodFormattedDate, AFTConstants.YYYYMMDD);
+			} catch (ParseException e) {
+			}
+		}
+		
+		if (null!=TokenManager.getUserId()) {
+			d.setEmployerId(TokenManager.getUserId());
+			d.setInfoSources(1);
+			User u=userMapper.selectByPrimaryKey(TokenManager.getUserId());
+			
+			if (null!=u.getType()) {
+				d.setDataCategory(u.getType());
+			}
+			if (StringUtils.isNotBlank(u.getId())) {
+				d.setEmployerId(u.getId());
+			}
+			
+			if (StringUtils.isNotBlank(u.getMobile())) {
+				d.setEmployerContactsMobile(u.getMobile());
+			}
+		}
+		d.setValidityPeriod(validityPeriod);
+		d.setId(UUID.randomUUID().toString());
+		d.setTechBrokerId(TokenManager.getAdminId());
+
+		d.setDeletedSign(DeleteStatus.UNDELETE.getCode());
+
+		Calendar now = Calendar.getInstance();
+		now.set(Calendar.MILLISECOND, 0);
+		d.setStatus(DemandStatus.UNRESOLVED.getCode());
+		d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
+
+		d.setPrincipalId(TokenManager.getAdminId());
+		if (DemandAuditStatus.SUBMIT.getCode().equals(d.getAuditStatus())) {
+			d.setAuditStatus(DemandAuditStatus.INAUDIT.getCode());
+			createAuditorNotice(d);
+		} else {
+			d.setAuditStatus(DemandAuditStatus.CREATE.getCode());
+		}
+
+		d.setCreateTime(now.getTime());
+		demandMapper.insert(d);
+		disposeDemandKeyword(keywords, d, false);
+	}
+
 	
 		
 	

+ 79 - 0
src/main/java/com/goafanti/portal/controller/PortalServicesController.java

@@ -0,0 +1,79 @@
+package com.goafanti.portal.controller;
+
+
+
+import javax.annotation.Resource;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.goafanti.business.service.BusinessProjectService;
+import com.goafanti.business.service.BusinessVarietiesService;
+import com.goafanti.common.bo.Result;
+import com.goafanti.common.constant.ErrorConstants;
+import com.goafanti.common.controller.BaseController;
+import com.goafanti.common.utils.StringUtils;
+import com.goafanti.order.service.OrderService;
+import com.goafanti.user.service.UserIdentityService;
+
+@RestController
+@RequestMapping(value = "/portal/app/services")
+public class PortalServicesController extends BaseController {
+	@Resource
+	BusinessProjectService	businessProjectService;
+	@Resource
+	UserIdentityService	userIdentityService;
+	@Resource
+	BusinessVarietiesService	businessVarietiesService;
+	@Resource
+	OrderService	orderService;
+	
+	
+	
+	/**
+	 * 推荐列表
+	 */
+	@RequestMapping(value = "/recommend", method = RequestMethod.GET)
+	public Result recommendProjectList(Integer pNo,Integer pSize) {
+		Result res = new Result();
+		res.setData(businessProjectService.portalRecommendList( pNo, pSize));
+		return res;
+	}
+	
+	/**
+	 * 一对一
+	 */
+	@RequestMapping(value = "/consultant", method = RequestMethod.GET)
+	public Result consultantList(Integer pNo,Integer pSize) {
+		Result res = new Result();
+		res.setData(userIdentityService.portalConsultantList( pNo, pSize));
+		return res;
+	}
+	
+	/**
+	 * 获取初级品类
+	 */
+	@RequestMapping(value = "/portal/services/varieties", method = RequestMethod.GET)
+	public Result getVarieties() {
+		Result res = new Result();
+		res.setData(businessVarietiesService.portalVarieties());
+		return res;
+	}
+	
+	/**
+	 * 获取品类下的项目
+	 */
+	@RequestMapping(value = "/businessProject", method = RequestMethod.GET)
+	public Result getBusinessProject(String id,Integer pNo,Integer pSize) {
+		Result res = new Result();
+		if (StringUtils.isBlank(id)) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"品类必须指定","品类"));
+			return res;
+		}
+		res.setData(businessProjectService.portalBusinessProject(id,pNo, pSize));
+		return res;
+	}
+	
+}