package com.cyksj.web.controller.mirror;

import com.cyksj.dto.Result;
import com.cyksj.enums.GatewayResponse;
import com.cyksj.model.entity.MirrorNotice;
import com.ejlchina.searcher.BeanSearcher;
import com.ejlchina.searcher.SearchResult;
import com.ejlchina.searcher.util.MapUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 *  镜像系统公告
 * @author chan
 * @date 2024/6/21 14:40
 */
@RestController
@RequestMapping("/applets/mirror/notice")
@RequiredArgsConstructor
@Slf4j
public class MirrorNoticeController {

    private final BeanSearcher beanSearcher;

    private final HttpServletRequest request;

    /**
     * 查看公告列表
     */
    @GetMapping
    private Result<SearchResult<MirrorNotice>> get(){
        return GatewayResponse.SUCCESS.newBuilder().toResult( beanSearcher.search(MirrorNotice.class, MapUtils.flatBuilder(request.getParameterMap()).field(MirrorNotice::getStatus, true).build()));
    }

}
