package com.xly.erp.module.usr.mapper;

import com.xly.erp.module.usr.vo.PermissionCategoryVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PermissionCategoryMapper {

    @Select("<script>"
            + "SELECT COUNT(1) FROM tPermissionCategory "
            + "WHERE bDeleted = 0 AND iIncrement IN "
            + "<foreach collection='ids' item='id' open='(' separator=',' close=')'>#{id}</foreach>"
            + "</script>")
    int countActiveByIds(@Param("ids") List<Integer> ids);

    @Select("SELECT iIncrement, sCategoryCode, sCategoryName, iParentId, iSortOrder "
            + "FROM tPermissionCategory "
            + "WHERE bDeleted = 0 "
            + "ORDER BY iSortOrder ASC, iIncrement ASC")
    List<PermissionCategoryVO> listActive();
}
