package com.hc.business.service.impl;

import com.hc.business.mapper.NewsTagMapper;
import com.hc.business.model.NewsTag;
import com.hc.business.service.NewsTagService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 新闻标签表(NewsTag)表服务实现类
 *
 * @author java
 * @since 2020-11-20 12:52:33
 */

@Service("newsTagService")
public class NewsTagServiceImpl implements NewsTagService {

    private final NewsTagMapper newsTagMapper;

    public NewsTagServiceImpl(NewsTagMapper newsTagMapper) {
        this.newsTagMapper = newsTagMapper;
    }

    /**
     * 通过ID查询单条数据
     *
     * @param tagId 主键
     * @return 实例对象
     */
    @Override
    public NewsTag queryById(Integer tagId) {
        return this.newsTagMapper.selectByPrimaryKey(tagId);
    }

    /**
     * 新增数据
     *
     * @param newsTag 实例对象
     * @return 实例对象
     */
    @Override
    public NewsTag insert(NewsTag newsTag) {
        this.newsTagMapper.insert(newsTag);
        return newsTag;
    }

    /**
     * 修改数据
     *
     * @param newsTag 实例对象
     * @return 实例对象
     */
    @Override
    public NewsTag update(NewsTag newsTag) {
        this.newsTagMapper.updateByPrimaryKeySelective(newsTag);
        return newsTag;
    }

    /**
     * 通过主键删除数据
     *
     * @param tagId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer tagId) {
        return this.newsTagMapper.deleteByPrimaryKey(tagId) > 0;
    }

    @Override
    public List<NewsTag> queryAll() {
        return this.newsTagMapper.queryAll();
    }



}