package cn.common.repository.repository;

import cn.common.repository.entity.GridArchives;
import cn.common.common.repository.BaseRepository;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author Singer create by singer email:singer-coder@qq.com
* @packageName cn.singer.repository.entity
* @Description: 网格-健康档案关联信息->Repository
* @date 2019-08-12
*/
@Mapper
public interface GridArchivesRepository extends BaseRepository<GridArchives> {


        /**
         * 根据网格信息查询健康档案
         * @title: AuthRoleRepository.java
         * @author create by Singer - Singer email:singer-coder@qq.com
         * @date 2019/4/28 11:05
         * @param gridUnitId 网格ID
         * @return List
         */
        @Select(
                "<script>" +
                        " SELECT health_archives_id AS gridArchivesId FROM grid_archives WHERE 1=1 AND  " +
                        " grid_unit_id = #{gridUnitId} " +
                        "</script>"
        )
        List<String> selectByGridUnitId(@Param("gridUnitId") String gridUnitId);

        /**
         * 根据业务主键批量删除
         * @title: AuthRoleRepository.java
         * @author create by Singer - Singer email:singer-coder@qq.com
         * @date 2019/4/28 11:05
         * @param healthArchivesId 健康档案ID
         * @return List
         */
        @Delete(
                "<script>" +
                " DELETE FROM grid_archives WHERE 1=1 AND  " +
                " health_archives_id = #{healthArchivesId} " +
                "</script>"
        )
        void deleteByArchivesId(@Param("healthArchivesId") String healthArchivesId);

        /**
         * 根据业务主键批量删除
         * @title: AuthRoleRepository.java
         * @author create by Singer - Singer email:singer-coder@qq.com
         * @date 2019/4/28 11:05
         * @param mainIdList 业务主键ID集合
         * @return List
         */
        @Delete(
            "<script>" +
            " DELETE FROM grid_archives WHERE 1=1 AND  " +
            " grid_archives_id IN " +
            " <foreach collection='mainIdList' item= 'item' index= 'index' open='(' separator=',' close=')' >" +
            "   #{item} " +
            " </foreach>" +
            "</script>"
            )
        void batchDeleteItem(@Param("mainIdList") List<String> mainIdList);
}
