package com.yonge.cooleshow.student.controller.open;

import io.swagger.annotations.Api;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
import com.yonge.cooleshow.auth.api.entity.SysUser;
import com.yonge.cooleshow.biz.dal.service.ActivityEvaluationRecordService;
import com.yonge.cooleshow.biz.dal.vo.ActivityRankingVo;
import com.yonge.cooleshow.common.controller.BaseController;
import com.yonge.cooleshow.common.entity.HttpResponseResult;

@RestController
@RequestMapping("/open/activityEvaluationRecord")
@Api(value = "评测活动表", tags = "评测活动表")
public class ActivityEvaluationRecordController extends BaseController {

    @Autowired
    private ActivityEvaluationRecordService activityEvaluationRecordService;
	@Resource
	private SysUserFeignService sysUserFeignService;

    /**
     * 查询活动排行榜
     */
    @GetMapping("/queryRankingList")
	public HttpResponseResult<ModelMap> queryRankingList(Long activityPlanId, Long activityEvaluationId, int limit) {

        ModelMap model = new ModelMap();
        
        SysUser user = sysUserFeignService.queryUserInfo();
        if (user != null && null != user.getId()) {
            ActivityRankingVo userActivityRankingVo = activityEvaluationRecordService.queryUserRanking(activityPlanId, activityEvaluationId, user.getId());
            model.put("userActivityRankingVo", userActivityRankingVo);
        }
        
    	List<ActivityRankingVo> rankingList =  activityEvaluationRecordService.queryRankingList(activityPlanId, activityEvaluationId, limit);
    	model.put("rankingList", rankingList);
    	
        return succeed(model);
	}

}