package cn.iocoder.yudao.server.controller.admin;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.server.dal.dataobject.OaDocDO;
import cn.iocoder.yudao.server.dal.mysql.OaMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import java.util.List;
import java.util.Map;

@Tag(name = "管理后台 - 门户首页接口")
@RestController
@RequestMapping("/portal/home")
@Validated
public class HomeController {

    @Resource
    private OaMapper oaMapper;

    @GetMapping("/red")
    @PermitAll
    public CommonResult<PageResult<OaDocDO>> redFile(Integer pageNo,Integer pageSize) {
        Page<OaDocDO> page = new Page<>(pageNo, pageSize);
        IPage<OaDocDO> oaDocDOIPage = oaMapper.selectOaDocPage(page, ImmutableList.of(28, 143));
        PageResult<OaDocDO> result = new PageResult<>(oaDocDOIPage.getRecords(), oaDocDOIPage.getTotal());
        return CommonResult.success(result);
    }

    @GetMapping("/notice")
    @PermitAll
    public CommonResult<PageResult<OaDocDO>> noticeFile(Integer pageNo,Integer pageSize) {
        Page<OaDocDO> page = new Page<>(pageNo, pageSize);
        IPage<OaDocDO> oaDocDOIPage = oaMapper.selectOaDocPage(page, ImmutableList.of(25));
        PageResult<OaDocDO> result = new PageResult<>(oaDocDOIPage.getRecords(), oaDocDOIPage.getTotal());
        return CommonResult.success(result);
    }

    @GetMapping("/news")
    @PermitAll
    public CommonResult<PageResult<OaDocDO>> newsFile(Integer pageNo,Integer pageSize) {
        Page<OaDocDO> page = new Page<>(pageNo, pageSize);
        IPage<OaDocDO> oaDocDOIPage = oaMapper.selectOaDocPage(page, ImmutableList.of(14));
        PageResult<OaDocDO> result = new PageResult<>(oaDocDOIPage.getRecords(), oaDocDOIPage.getTotal());
        return CommonResult.success(result);
    }
}
