package com.crm.manager.controller;

import com.crm.manager.service.activity.WebNoticeFeignService;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
import com.crm.rely.backend.core.dto.web.notice.WebNoticeDto;
import com.crm.rely.backend.core.dto.web.notice.record.WebNoticeRecordDto;
import com.crm.rely.backend.core.dto.web.upload.WebUploadCidDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.web.notice.WebNoticeAddEntity;
import com.crm.rely.backend.core.entity.web.notice.WebNoticeSearchPageEntity;
import com.crm.rely.backend.core.entity.web.notice.record.WebNoticeRecordSearchPageEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 群发通知
 *
 * @author houn
 */
@RestController
@RequestMapping("/web/notice")
public class WebNoticeController {

    @Autowired
    private WebNoticeFeignService webNoticeFeignService;

    /**
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/add")
    public BaseResultDto add(@RequestBody @Validated WebNoticeAddEntity entity) throws Exception {

        return webNoticeFeignService.add(entity);
    }

    @PostMapping("/add/upload/cid")
    public BaseResultDto<List<WebUploadCidDto>> getUploadCidList() throws Exception {
        return webNoticeFeignService.getUploadCidList();
    }

    @PostMapping("/search/list")
    public ResultWithPagerDto<WebNoticeDto> pageList(@RequestBody @Validated WebNoticeSearchPageEntity entity) throws Exception {
        return webNoticeFeignService.pageList(entity);
    }

    @PostMapping("/search/single")
    public BaseResultDto<WebNoticeDto> single(@RequestBody @Validated SingleLongEntity entity) throws Exception {

        return webNoticeFeignService.single(entity);
    }

    /**
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/search/list/record")
    public ResultWithPagerDto<WebNoticeRecordDto> pageListRecord(@RequestBody @Validated WebNoticeRecordSearchPageEntity entity) throws Exception {
        return webNoticeFeignService.pageListRecord(entity);
    }

}
