package com.yonge.cooleshow.admin.controller;

import com.yonge.cooleshow.biz.dal.dto.req.TotalReq;
import com.yonge.cooleshow.biz.dal.service.HomeService;
import com.yonge.cooleshow.biz.dal.vo.res.HomeTotalStudent;
import com.yonge.cooleshow.biz.dal.vo.res.HomeTotalTeacher;
import com.yonge.cooleshow.biz.dal.vo.res.HomeUserToDoNum;
import com.yonge.cooleshow.common.controller.BaseController;
import com.yonge.cooleshow.common.entity.HttpResponseResult;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/home")
@Api(value = "首页", tags = "首页")
public class HomeController extends BaseController {
    @Autowired
    private HomeService homeService;

    @ApiOperation(value = "查询用户待办事项数")
    @PostMapping("/getUserToDoNum")
    @PreAuthorize("@pcs.hasPermissions('home/getUserToDoNum')")
    public HttpResponseResult<HomeUserToDoNum> getUserToDoNum() {
        return succeed(homeService.getUserToDoNum());
    }

    @ApiOperation(value = "老师数据统计")
    @PostMapping("/totalTeacher")
    @PreAuthorize("@pcs.hasPermissions('home/totalTeacher')")
    public HttpResponseResult<HomeTotalTeacher> totalTeacher(@Valid @RequestBody TotalReq totalReq) {
        return homeService.totalTeacher(totalReq);
    }

    @ApiOperation(value = "学员数据统计")
    @PostMapping("/totalStudent")
    @PreAuthorize("@pcs.hasPermissions('home/totalStudent')")
    public HttpResponseResult<HomeTotalStudent> totalStudent(@Valid @RequestBody TotalReq totalReq) {
        return homeService.totalStudent(totalReq);
    }

}