package com.mcwl.communityCenter.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.communityCenter.domain.Community;
import com.mcwl.communityCenter.domain.CommunityAdvice;
import com.mcwl.communityCenter.domain.dto.CommunityAdvicePageRes;
import com.mcwl.communityCenter.domain.vo.CommunityAdviceVo;
import com.mcwl.communityCenter.mapper.CommunityAdviceMapper;
import com.mcwl.communityCenter.mapper.CommunityMapper;
import com.mcwl.communityCenter.service.CommunityAdviceService;
import com.mcwl.communityCenter.service.CommunityService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommunityAdviceServiceImpl extends ServiceImpl<CommunityAdviceMapper, CommunityAdvice>
        implements CommunityAdviceService {


    @Override
    public TableDataInfo getCommunityAdviceList(CommunityAdvicePageRes communityAdvicePageRes) {
        Page<CommunityAdvice> page = new Page<>(communityAdvicePageRes.getPageNum(), communityAdvicePageRes.getPageSize());
        List<CommunityAdviceVo> communityAdviceList = baseMapper.getCommunityAdviceList(page, communityAdvicePageRes);


        // 封装分页信息
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setMsg("查询成功");
        rspData.setRows(communityAdviceList);
        rspData.setTotal(page.getTotal());
        return rspData;
    }
}
