package com.ruoyi.dxp.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.dxp.mapper.TagGroupMapper;
import com.ruoyi.dxp.domain.TagGroup;
import com.ruoyi.dxp.service.ITagGroupService;

/**
 * 标签分组Service业务层处理
 * 
 * @author jy
 * @date 2022-11-06
 */
@Service
public class TagGroupServiceImpl implements ITagGroupService 
{
    @Autowired
    private TagGroupMapper tagGroupMapper;

    /**
     * 查询标签分组
     * 
     * @param id 标签分组主键
     * @return 标签分组
     */
    @Override
    public TagGroup selectTagGroupById(Long id)
    {
        return tagGroupMapper.selectTagGroupById(id);
    }

    /**
     * 查询标签分组列表
     * 
     * @param tagGroup 标签分组
     * @return 标签分组
     */
    @Override
    public List<TagGroup> selectTagGroupList(TagGroup tagGroup)
    {
        return tagGroupMapper.selectTagGroupList(tagGroup);
    }

    /**
     * 新增标签分组
     * 
     * @param tagGroup 标签分组
     * @return 结果
     */
    @Override
    public int insertTagGroup(TagGroup tagGroup)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        tagGroup.setCreateBy(loginUser.getUsername());
        tagGroup.setCreateTime(DateUtils.getNowDate());
        return tagGroupMapper.insertTagGroup(tagGroup);
    }

    /**
     * 修改标签分组
     * 
     * @param tagGroup 标签分组
     * @return 结果
     */
    @Override
    public int updateTagGroup(TagGroup tagGroup)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        tagGroup.setUpdateBy(loginUser.getUsername());
        tagGroup.setUpdateTime(DateUtils.getNowDate());
        return tagGroupMapper.updateTagGroup(tagGroup);
    }

    /**
     * 批量删除标签分组
     * 
     * @param ids 需要删除的标签分组主键
     * @return 结果
     */
    @Override
    public int deleteTagGroupByIds(Long[] ids)
    {
        return tagGroupMapper.deleteTagGroupByIds(ids);
    }

    /**
     * 删除标签分组信息
     * 
     * @param id 标签分组主键
     * @return 结果
     */
    @Override
    public int deleteTagGroupById(Long id)
    {
        return tagGroupMapper.deleteTagGroupById(id);
    }
}
