package com.goafanti.app.controller; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import com.goafanti.app.service.AppHomePageService; import com.goafanti.business.service.JtBusinessService; import com.goafanti.comment.bo.CommentResult; import com.goafanti.comment.service.CommentService; 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.utils.StringUtils; @RestController @RequestMapping(path = "/open/app/home") public class OpenAppHomeController extends BaseApiController{ @Resource private AppHomePageService appHomePageService; @Resource private JtBusinessService jtBusinessService; @Resource private CommentService commentService; /**App首页轮播图、导航、知产*/ @RequestMapping(value = "/getHomePageData", method = RequestMethod.GET) public Result getHomePageData(HttpServletRequest request){ Result res = new Result(); res.setData(appHomePageService.getAppHomePage(request)); return res; } /**技淘推荐*/ @RequestMapping(value = "/getHomeRecommended", method = RequestMethod.GET) public Result getHomeRecommended(Integer type){ Result res = new Result(); if (null==type||type>3||type<0) { res.getError().add(buildError( "类型错误", "类型错误")); return res; } res.setData(appHomePageService.getHomeRecommended(type)); return res; } /** * 项目列表 * @param topId * @param secondId * @param name * @param pageSize * @param pageNo * @param privateProject * @param auditStatus * @param module * @param isHot * @param orderType * @param orderSort * @param ownerId * @return */ @RequestMapping(value="/projectList", method=RequestMethod.GET) public Result getProjectList(String topId,String secondId,String name,Integer pageSize,Integer pageNo,Integer privateProject,Integer auditStatus,Integer module,Integer isHot,Integer orderType,Integer orderSort,String ownerId) { Result result=new Result(); result.setData(jtBusinessService.getProjects(topId,secondId,name,pageSize,pageNo,privateProject,auditStatus,module,isHot,orderType,orderSort,ownerId)); return result; } /** * 项目详情 * @param id * @return */ @RequestMapping(value="/projectdDtail",method=RequestMethod.GET) public Result projectdDtail(String id){ Result result =new Result(); if (StringUtils.isBlank(id)) { result.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"商品ID","商品ID")); return result; } result.setData(jtBusinessService.getBusinessProjectDetail(id)); return result; } /** * 项目评价 * @param id * @return */ @RequestMapping(value = "/projectdComment", method = RequestMethod.GET) public Result listComment(String id,Integer pageNo,Integer pageSize) { Result result=new Result(); if(StringUtils.isBlank(id)) { result.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"商品ID","商品ID")); } CommentResult commentResult=new CommentResult(); commentResult.setPositiveCommentCount(commentService.getCommentCount(0, id)); commentResult.setOrdinaryCommentCount(commentService.getCommentCount(1, id)); commentResult.setNegativeCommentCount(commentService.getCommentCount(2, id)); commentResult.setComments(commentService.searchComment(id, pageNo, pageSize)); result.setData(commentResult); return result; } }