package com.yh.saas.plugin.news.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.winsea.svc.base.base.view.CommonTreeView;
import com.yh.saas.plugin.news.entity.AnnoIssueInfo;
import com.yh.saas.plugin.news.entity.CommonAnnouncementIssueInfo;
import com.yh.saas.plugin.news.service.INewsAnnouncementInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 新闻
 * </p>
 *
 * @Auther Wangs
 * @since 2020年2月19日16:00:32
 */
@RestController
@RequestMapping("/commonAnnIssueInfo")
public class NewsCommonAnnIssueInfoController {

    @Autowired
    private INewsAnnouncementInfoService announcementInfoService;

    /**
     * 创建新闻信息
     *
     * @param commonIssueInfo
     * @return
     */
    @PostMapping("/api/createCommonIssueInfo")
    public String createCommonIssueInfo(@RequestBody CommonAnnouncementIssueInfo commonIssueInfo) {
        return announcementInfoService.createCommonIssueInfo(commonIssueInfo);
    }

    /**
     * 更新新闻信息
     *
     * @param commonIssueInfo
     * @return
     */
    @PostMapping("/api/updateCommonIssueInfo")
    public String updateCommonIssueInfo(@RequestBody CommonAnnouncementIssueInfo commonIssueInfo) {
        return announcementInfoService.updateCommonIssueInfo(commonIssueInfo);
    }

    /**
     * 删除
     *
     * @param commonIssueInfo
     */
    @PostMapping("/api/remove")
    public void remove(@RequestBody CommonAnnouncementIssueInfo commonIssueInfo) {
        announcementInfoService.remove(commonIssueInfo);
    }

    /**
     * 查询系统新闻一览信息
     *
     * @param issueInfo 查询条件
     * @return
     */
    @GetMapping("/query/queryCommonPage")
    public Page<CommonAnnouncementIssueInfo> queryCommonPage(CommonAnnouncementIssueInfo issueInfo) {
        return announcementInfoService.queryCommonPage(issueInfo);
    }

    /**
     * 查询 系统新闻详情
     *
     * @param commonIssueInfo 查询条件
     * @return
     */
    @GetMapping("/query/queryCommonDetail")
    public CommonAnnouncementIssueInfo queryCommonDetail(CommonAnnouncementIssueInfo commonIssueInfo) {
        return announcementInfoService.queryCommonDetail(commonIssueInfo);
    }

    /**
     * 查询所有租户的已发布的新闻
     *
     * @param annoIssueInfo 查询条件
     * @return
     */
    @GetMapping("/query/queryTenantPage")
    public Page<AnnoIssueInfo> queryTenantPage(AnnoIssueInfo annoIssueInfo) {
        return announcementInfoService.queryTenantPage(annoIssueInfo);
    }

    /**
     * 查询 租户的已发布的新闻详细
     *
     * @param annoIssueInfo 查询条件
     * @return
     */
    @GetMapping("/query/queryTenantDetail")
    public AnnoIssueInfo queryTenantDetail(AnnoIssueInfo annoIssueInfo) {
        return announcementInfoService.queryTenantDetail(annoIssueInfo);
    }

    /**
     * 获取接收范围信息
     */
    @GetMapping("/query/getSendScopeList")
    public List<CommonTreeView> getSendScopeList() {
        return announcementInfoService.getSendScopeList();
    }

}
