package cn.iocoder.yudao.module.system.api.notice;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.api.notice.dto.NoticeDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO;
import cn.iocoder.yudao.module.system.dal.mysql.notice.NoticeMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class NoticeApiImpl implements NoticeApi {

    @Resource
    private NoticeMapper noticeMapper;

    @Override
    public CommonResult<Long> count(NoticeDTO reqDTO) {
        Long count = noticeMapper.selectCount(new LambdaQueryWrapper<NoticeDO>()
                .between(NoticeDO::getCreateTime, reqDTO.getBeginTime(), reqDTO.getEndTime())
                .eq(NoticeDO::getStatus, reqDTO.getStatus()));
        return success(count);
    }
}
