package com.ym.mec.web.controller;

import com.ym.mec.biz.dal.page.ExtraExercilseReplyQueryInfo;
import com.ym.mec.biz.service.ExtracurricularExercisesReplyService;
import com.ym.mec.biz.service.OrganizationService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.entity.HttpResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "课外训练学生作业服务")
@RequestMapping("extracurricularExercisesReply")
@RestController
public class ExtracurricularExercisesReplyController extends BaseController {

    @Autowired
    private ExtracurricularExercisesReplyService extracurricularExercisesReplyService;
    @Autowired
    private OrganizationService organizationService;

    @ApiOperation(value = "获取课外训练作业列表")
    @GetMapping("/queryPageList")
    private HttpResponseResult findExtraExercilses(ExtraExercilseReplyQueryInfo queryInfo){
        queryInfo.setOrganIdList(organizationService.getEmployeeOrgan(queryInfo.getOrganIdList()));
        return succeed(extracurricularExercisesReplyService.findExtraExercises(queryInfo));
    }

    @GetMapping("/exercisesSituationStatistics")
    public HttpResponseResult exercisesSituationStatistics(String monday){
        if(StringUtils.isNotBlank(monday)){
            extracurricularExercisesReplyService.exercisesSituationStatistics2(monday);
        }else{
            String[] mondays=new String[]{"2020-05-13","2020-05-20","2020-05-27"};
            for (String mondayStr : mondays) {
                extracurricularExercisesReplyService.exercisesSituationStatistics2(mondayStr);
            }
        }
        return succeed();
    }
}
