package com.hz.pm.api.meta.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hz.pm.api.meta.assembler.MetaTagAssembler;
import com.hz.pm.api.meta.mapper.MetaTagMapper;
import com.hz.pm.api.meta.model.dto.TagDTO;
import com.hz.pm.api.meta.model.entity.MetaTag;
import com.hz.pm.api.meta.service.IMetaTagService;
import com.ningdatech.basic.util.CollUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Liuxinxin
 * @since 2023-02-22
 */
@Service
public class MetaTagServiceImpl extends ServiceImpl<MetaTagMapper, MetaTag> implements IMetaTagService {


    @Override
    public List<TagDTO> queryAll() {
        List<MetaTag> allTags = this.lambdaQuery().ne(MetaTag::getId, -1).list();
        return CollUtils.convert(allTags, MetaTagAssembler::convert);
    }

    @Override
    public List<TagDTO> queryLeLevel(int level) {
        List<MetaTag> allTags = this.lambdaQuery()
                .ne(MetaTag::getId, -1)
                .le(MetaTag::getTagLevel, level)
                .list();
        return CollUtils.convert(allTags, MetaTagAssembler::convert);
    }


}
