package com.test.bijihoudaun.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.test.bijihoudaun.entity.Grouping;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface GroupingMapper extends BaseMapper<Grouping> {

    @Select("SELECT id, parentId, `grouping`, is_deleted, deleted_at, deleted_by FROM `grouping` WHERE is_deleted = 1")
    List<Grouping> selectDeleted();

    @Delete("DELETE FROM `grouping` WHERE id = #{id}")
    void physicalDeleteById(@Param("id") Long id);

    @Update("UPDATE `grouping` SET is_deleted = 0, deleted_at = NULL, deleted_by = NULL WHERE id = #{id}")
    void restoreById(@Param("id") Long id);
    @Delete("DELETE FROM `grouping` WHERE is_deleted = 1")
    void physicalDeleteByIsDeleted();
}