package link.at17.mid.tushare.web.controller;

import java.util.Collection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.Validator;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import link.at17.mid.tushare.data.models.UpdateMethodInfo;
import link.at17.mid.tushare.data.models.UpdatePlan;
import link.at17.mid.tushare.dto.LayPageReq;
import link.at17.mid.tushare.dto.LayPageResp;
import link.at17.mid.tushare.service.UpdateMethodService;
import link.at17.mid.tushare.service.UpdatePlanService;
import lombok.extern.slf4j.Slf4j;

@Controller
@RequestMapping("/admin/manage/reviews/update-methods")
@Slf4j
public class UpdateMethodController extends BaseController {

    @Autowired
    Validator validator;
    
    @Autowired
    UpdateMethodService updateMethodService;
    
    @Autowired
    UpdatePlanService updatePlanService;
    
    @GetMapping("/plan-list")
    public String planList() {
        return "admin/manage/reviews/plans/plan-list";
    }
    
    @GetMapping("/method-list-resp")
    @ResponseBody
    public Collection<UpdateMethodInfo> updateMethodInfoList() {
        return updateMethodService.getPotentialUpdateMethodInfos();
    }

    @GetMapping("/list")
    @ResponseBody
    public LayPageResp<?> list(LayPageReq<UpdatePlan> req) {
        return new LayPageResp<>(updatePlanService.page(req));
    }

}
