|
|
@@ -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) {
|