package com.hzs.system.base.provider;

import cn.hutool.core.bean.BeanUtil;
import com.hzs.common.core.domain.R;
import com.hzs.system.base.IApprovalPushInfo;
import com.hzs.system.base.dto.ApprovalPushInfoDTO;
import com.hzs.system.base.service.IBdPlatformMessageService;
import com.hzs.system.base.vo.BdPlatformMessageDetailVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 后台站内信服务
 */
@Slf4j
@DubboService
public class PlatformMessageServiceProvider implements IApprovalPushInfo {

    @Autowired
    private IBdPlatformMessageService bdPlatformMessageService;

    @Override
    public R approvalPushInfo(List<ApprovalPushInfoDTO> approvalPushInfoDTOList) {
        List<BdPlatformMessageDetailVO> bdPlatformMessageDetailVOList = BeanUtil.copyToList(approvalPushInfoDTOList, BdPlatformMessageDetailVO.class);
        try {
            Boolean result = bdPlatformMessageService.approvalPushInfo(bdPlatformMessageDetailVOList);
            if (result) {
                return R.ok();
            }
            return R.fail();
        } catch (Exception e) {
            return R.fail(e.getMessage());
        }
    }
}
