Browse Source

Merge remote-tracking branch 'origin/dev' into test

wanghui 8 years ago
parent
commit
f7059781d6
1 changed files with 23 additions and 54 deletions
  1. 23 54
      src/main/java/com/goafanti/app/controller/AppApiController.java

+ 23 - 54
src/main/java/com/goafanti/app/controller/AppApiController.java

@@ -1,78 +1,47 @@
 package com.goafanti.app.controller;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 
-import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
-import com.goafanti.achievement.service.AchievementService;
-import com.goafanti.activity.service.ActivityService;
-import com.goafanti.banners.enums.BannersType;
-import com.goafanti.banners.service.BannersService;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.BaseApiController;
-import com.goafanti.demand.service.DemandService;
-import com.goafanti.news.enums.NewsType;
-import com.goafanti.news.service.NewsService;
+import com.goafanti.common.model.User;
+import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.user.service.UserService;
 
 @RestController
-@RequestMapping(path = "/api/open/app", method = RequestMethod.GET)
+@RequestMapping(path = "/api/user/app", method = RequestMethod.GET)
 public class AppApiController extends BaseApiController {
-	@Resource
-	private BannersService		bannersService;
-	@Resource
-	private ActivityService		activityService;
-	@Resource
-	private NewsService			newsService;
-	@Resource
-	private AchievementService	achievementService;
-	@Resource
-	private DemandService		demandService;
-	@RequestMapping(value = "/index", method = RequestMethod.GET)
-	public Result index(HttpServletRequest request) {
-		Map<String, Object> result = new HashMap<>();
-		String domainName = request.getServerName();
-		result.put("banners", bannersService.findPortalBanners(BannersType.APP.getKey()));
-		result.put("activities", activityService.findPortalList(0, 3, null));
-		result.put("policies", newsService.findNewsList(0, NewsType.GJZC.getCode(), 3, domainName, true));
-		result.put("news", newsService.findNewsList(0, NewsType.JTDT.getCode(), 5, domainName, true));
-		return res().data(result);
-	}
-
-	/**
-	 * 科技成果详情
-	 */
-	@RequestMapping(value = "/achievementDetail", method = RequestMethod.GET)
-	public Result achievementDetail(String id) {
+	@Autowired
+	private UserService userServiceImpl;
+	
+	@RequestMapping(value = "/uploadImg",method = RequestMethod.POST)
+	public Result uploadAvatar(HttpServletRequest req){
 		Result res = new Result();
-		if (StringUtils.isBlank(id)) {
-			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到成果ID", "成果ID"));
-			return res;
+		String headPortraitUrl = handleFile(res, "/avatar/", false, req, "");
+		if(TokenManager.getToken() instanceof User){
+			User u = (User)TokenManager.getToken();
+			u.setHeadPortraitUrl(headPortraitUrl);
+			userServiceImpl.updateByPrimaryKeySelective(u);
 		}
-		res.setData(achievementService.selectAchievementDetail(id));
+		res.setData(headPortraitUrl);
 		return res;
 	}
 
-	/**
-	 * 科技需求详情
-	 */
-	@RequestMapping(value = "/demandDetail", method = RequestMethod.GET)
-	public Result demandDetail(String id) {
+	@RequestMapping(value = "/updateUser",method = RequestMethod.POST)
+	public Result updateUser(User u){
 		Result res = new Result();
-		if (StringUtils.isBlank(id)) {
-			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
-			return res;
+		if(null != u){
+			u.setId(TokenManager.getUserId());
+			userServiceImpl.updateByPrimaryKeySelective(u);
+		}else{
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR));
 		}
-		res.setData(demandService.selectDemandDetail(id));
 		return res;
 	}
-	
-
 }