package com.corewing.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.corewing.app.common.page.PageContext;
import com.corewing.app.entity.TutorialCategory;
import com.corewing.app.mapper.TutorialCategoryMapper;
import com.corewing.app.service.TutorialCategoryService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class TutorialCategoryServiceImpl extends ServiceImpl<TutorialCategoryMapper, TutorialCategory> implements TutorialCategoryService {

    public Page<TutorialCategory> page(TutorialCategory tutorialCategory){
        Page<TutorialCategory> page = PageContext.getDefaultPage(TutorialCategory.class);

        LambdaQueryWrapper<TutorialCategory> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(StringUtils.hasText(tutorialCategory.getCategoryTitle()), TutorialCategory::getCategoryTitle, tutorialCategory.getCategoryTitle());
        return page(page, queryWrapper);
    }

}
