package com.pcloud.book.cultivate.service.impl;

import com.pcloud.book.cultivate.biz.CultivateNotifyBiz;
import com.pcloud.book.cultivate.entity.AppletNotifySendDTO;
import com.pcloud.book.cultivate.entity.CultivateNotifySend;
import com.pcloud.book.cultivate.service.CultivateNotifyService;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.ListUtils;

import com.pcloud.common.utils.ResponseHandleUtil;
import com.pcloud.common.utils.bean.ResponesUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController("cultivateNotifyService")
@RequestMapping("cultivateNotifyService")
public class CultivateNotifyServiceImpl implements CultivateNotifyService {

    @Autowired
    private CultivateNotifyBiz cultivateNotifyBiz;

    @Override
    @RequestMapping(value = "/batchSendMiniUser", method = RequestMethod.POST)
    public void batchSendMiniUser(@RequestBody List<CultivateNotifySend> list) throws BizException {
        if (!ListUtils.isEmpty(list)) {
            cultivateNotifyBiz.batchSendMiniUser(list);
        }
    }

    @Override
    @RequestMapping(value = "sendAppletUserNotify", method = RequestMethod.POST)
    public void sendAppletUserNotify(@RequestBody List<CultivateNotifySend> list) throws BizException{
        if (!ListUtils.isEmpty(list)) {
            cultivateNotifyBiz.sendAppletUserNotify(list);
        }
    }

    @Override
    @RequestMapping(value = "createNotify4Question", method = RequestMethod.POST)
    public  ResponseEntity<ResponseDto<Long>> createNotify4Question(@RequestBody AppletNotifySendDTO newSendDTO)  throws BizException{
        return ResponseHandleUtil.toResponse(cultivateNotifyBiz.createNotify4Question(newSendDTO));
    }
}
