|
|
@@ -8,15 +8,20 @@ import java.util.UUID;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.validation.Valid;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.shiro.crypto.hash.SimpleHash;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
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;
|
|
|
import com.goafanti.achievement.service.AchievementService;
|
|
|
import com.goafanti.activity.service.ActivityService;
|
|
|
@@ -25,11 +30,15 @@ import com.goafanti.common.bo.Result;
|
|
|
import com.goafanti.common.constant.AFTConstants;
|
|
|
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.model.Achievement;
|
|
|
import com.goafanti.common.model.JpushEasemobAccount;
|
|
|
import com.goafanti.common.model.MessageConsumer;
|
|
|
import com.goafanti.common.model.MessageFromSystem;
|
|
|
import com.goafanti.common.model.MessageProducer;
|
|
|
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.service.DemandService;
|
|
|
@@ -45,7 +54,7 @@ import com.goafanti.user.service.UserInterestService;
|
|
|
import com.goafanti.user.service.UserService;
|
|
|
|
|
|
@RestController
|
|
|
-@RequestMapping(path = "/app/user", method = RequestMethod.GET)
|
|
|
+@RequestMapping(path = "/open/app/user", method = RequestMethod.GET)
|
|
|
public class AppUserController extends BaseApiController {
|
|
|
@Resource
|
|
|
private UserService userServiceImpl;
|
|
|
@@ -71,6 +80,10 @@ public class AppUserController extends BaseApiController {
|
|
|
private UserIdentityService userIdentityService;
|
|
|
@Resource
|
|
|
AchievementInterestService achievementInterestService;
|
|
|
+ @Resource
|
|
|
+ private FieldGlossoryService fieldGlossoryService;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@RequestMapping(value = "/uploadImg",method = RequestMethod.POST)
|
|
|
public Result uploadAvatar(HttpServletRequest req){
|
|
|
@@ -362,6 +375,98 @@ public class AppUserController extends BaseApiController {
|
|
|
res.setData(demandService.selectDemandDetail( id));
|
|
|
return res;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 新增成果
|
|
|
+ */
|
|
|
+
|
|
|
+ @RequestMapping(value = "/appAddAchievement", method = RequestMethod.POST)
|
|
|
+ private Result apply(@Valid InputAchievement ia, BindingResult bindingResult,
|
|
|
+ String keyword1,String keyword2,String keyword3) {
|
|
|
+ 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};
|
|
|
+ }
|
|
|
+ System.out.println( StringUtils.join(keywords,","));
|
|
|
+ ia.setKeyword(StringUtils.join(keywords,","));
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
|
|
|
+ AchievementFields.getFieldDesc(bindingResult.getFieldError().getField())));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ res = disposeInputAchievement(res, ia, keywords);
|
|
|
+ if (!res.getError().isEmpty()) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ Achievement a = new Achievement();
|
|
|
+ BeanUtils.copyProperties(ia, a);
|
|
|
+ achievementService.saveAchievement(a, keywords);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Result disposeInputAchievement(Result res, InputAchievement ia, String[] keywords) {
|
|
|
+ if (StringUtils.isBlank(ia.getName())) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到成果名称", "成果名称"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (null == ia.getCategory()) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到数据类别", "数据类别"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(ia.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 == ia.getCooperationMode()) {
|
|
|
+ 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) {
|
|
|
+ Result res = new Result();
|
|
|
+ AttachmentType attachmentType = AttachmentType.getField(sign);
|
|
|
+ if (attachmentType == AttachmentType.ACHIEVEMENT_TECHNICAL_PICTURE
|
|
|
+ || attachmentType == AttachmentType.ACHIEVEMENT_MATURITY_PICTURE
|
|
|
+ || attachmentType == AttachmentType.ACHIEVEMENT_COVER_PICTURE) {
|
|
|
+ res.setData(handleFiles(res, "/achievement/", false, req, sign, "achievement"));
|
|
|
+ } else {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取领域
|
|
|
+ * @param pid
|
|
|
+ * @param level
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getField", method = RequestMethod.POST)
|
|
|
+ public Result getField(Integer pid, Integer level) {
|
|
|
+ Result res = new Result();
|
|
|
+ res.setData(fieldGlossoryService.getField(pid, level));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/**
|