package com.ruoyi.liandao.service.impl;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.query.LambdaQueryWrapperX;
import com.ruoyi.liandao.domain.TourGuideInfo;
import com.ruoyi.liandao.dto.tourGuide.TourGuideInfoAddReqDto;
import com.ruoyi.liandao.dto.tourGuide.TourGuideInfoEditReqDto;
import com.ruoyi.liandao.dto.tourGuide.TourGuidePageReqDto;
import com.ruoyi.liandao.service.TourGuideInfoService;
import com.ruoyi.liandao.mapper.TourGuideInfoMapper;
import org.springframework.stereotype.Service;

/**
* @author admin
* @description 针对表【ld_tour_guide_info(导游信息配置)】的数据库操作Service实现
* @createDate 2024-03-14 10:51:09
*/
@Service
@DataSource(DataSourceType.MASTER)
public class TourGuideInfoServiceImpl extends ServiceImpl<TourGuideInfoMapper, TourGuideInfo>
    implements TourGuideInfoService{

    @Override
    public IPage<TourGuideInfo> getPage(TourGuidePageReqDto dto) {
        return page((IPage<TourGuideInfo>) dto.getPage(), new LambdaQueryWrapperX<TourGuideInfo>()
                .likeIfPresent(TourGuideInfo::getName, dto.getName())
                .orderByDesc(TourGuideInfo::getUpdateTime));
    }

    @Override
    public void add(TourGuideInfoAddReqDto dto) {
        TourGuideInfo tourGuideInfo = Convert.convert(TourGuideInfo.class, dto);
        save(tourGuideInfo);
    }

    @Override
    public void edit(TourGuideInfoEditReqDto dto) {
        TourGuideInfo tourGuideInfo = Convert.convert(TourGuideInfo.class, dto);
        updateById(tourGuideInfo);
    }
}




