package com.zhentao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhentao.entity.Tag;
import com.zhentao.mapper.TagMapper;
import com.zhentao.service.TagService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 标签Service实现类
 */
@Service
public class TagServiceImpl extends ServiceImpl<TagMapper, Tag> implements TagService {
    
    @Override
    public List<Tag> getAllActiveTags() {
        QueryWrapper<Tag> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("status", 1);
        queryWrapper.orderByAsc("id");
        return this.list(queryWrapper);
    }
    
    @Override
    public List<Tag> getActiveTagsByCategory(Integer categoryId) {
        QueryWrapper<Tag> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("status", 1);
        if (categoryId != null) {
            queryWrapper.eq("category_id", categoryId);
        }
        queryWrapper.orderByAsc("id");
        return this.list(queryWrapper);
    }
}

