package com.ym.mec.web.controller;

import com.ym.mec.biz.dal.page.TeacherCourseRewardQueryInfo;
import com.ym.mec.biz.service.OrganizationService;
import com.ym.mec.biz.service.TeacherCourseRewardService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.util.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RequestMapping("teacherCourseReward")
@Api(tags = "结转奖励服务")
@RestController
public class TeacherCourseRewardController extends BaseController {

    @Autowired
    private OrganizationService organizationService;
    @Autowired
    private TeacherCourseRewardService teacherCourseRewardService;


    @ApiOperation(value = "分页查询结转奖励")
    @GetMapping("/queryPage")
    @PreAuthorize("@pcs.hasPermissions('teacherCourseReward/queryPage')")
    public Object queryPage(TeacherCourseRewardQueryInfo queryInfo) {
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        Date endTime = queryInfo.getEndTime();
        if(endTime != null){
            queryInfo.setEndTime(DateUtil.addDays(endTime, 1));
        }
        return succeed(teacherCourseRewardService.queryPage(queryInfo));
    }
}
