package com.ym.mec.web.controller;

import com.ym.mec.biz.dal.dto.ChildrenDayMsgDto;
import com.ym.mec.biz.dal.dto.ChildrenStatisticsDetailDto;
import com.ym.mec.biz.dal.dto.ChildrenStatisticsDto;
import com.ym.mec.biz.dal.page.ChildrenReserveQueryInfo;
import com.ym.mec.biz.service.ChildrenDayReserveService;
import com.ym.mec.biz.service.OrganizationService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.entity.HttpResponseResult;
import com.ym.mec.common.page.PageInfo;
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.*;

import java.util.List;

@RequestMapping("childrenReserve")
@Api(tags = "儿童节活动")
@RestController
public class ChildrenReserveController extends BaseController {

    @Autowired
    private ChildrenDayReserveService childrenDayReserveService;
    @Autowired
    private OrganizationService organizationService;

    @ApiOperation(value = "21年暑期考级活动统计列表页面")
    @GetMapping("/queryStatisticsPage")
    @PreAuthorize("@pcs.hasPermissions('childrenReserve/queryStatisticsPage')")
    public HttpResponseResult<PageInfo<ChildrenStatisticsDto>> queryStatisticsPage(ChildrenReserveQueryInfo queryInfo) {
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        return succeed(childrenDayReserveService.queryStatisticsPage(queryInfo));
    }

    @ApiOperation(value = "21年暑期考级活动统计详情列表页面")
    @GetMapping("/queryStatisticsDetailPage")
    @PreAuthorize("@pcs.hasPermissions('childrenReserve/queryStatisticsDetailPage')")
    public HttpResponseResult<PageInfo<ChildrenStatisticsDetailDto>> queryStatisticsDetailPage(ChildrenReserveQueryInfo queryInfo) {
        return succeed(childrenDayReserveService.queryStatisticsDetailPage(queryInfo));
    }


    @ApiOperation(value = "发送短信和推送")
    @PostMapping("/sendMsg")
    @PreAuthorize("@pcs.hasPermissions('childrenReserve/sendMsg')")
    public HttpResponseResult sendMsg(@RequestBody List<ChildrenDayMsgDto> msgDto) {
        return succeed(childrenDayReserveService.sendMsg(msgDto));
    }
}
