package com.handong.smartservice.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

@Mapper
public interface BizGroupMapper {
    List<Map<String, Object>> selectBizGroup(Long biz_group_id, Boolean isCount, Long offset, Long limit, 
        String date_start, String date_end,
        String name, String biz_reg_num, String email, 
        String phone, String address);

    Map<String, Object> selectExistBizGroup(Long biz_group_id, String biz_reg_num);
    
    Map<String, Object> selectBizGroupByDeviceId(Long device_id);
    Map<String, Object> selectBizGroupByTerminalId(Long terminal_id);
    
    //int insertBizGroup(Long pid, String name, String biz_reg_num, Long gid, String email, 
    //    String phone, String ceo, String address);
    int insertBizGroup(Map<String, Object> params);

    int updateBizGroup(Long biz_group_id, Long pid, String name, String biz_reg_num, String email, 
        String phone, String ceo, String address);

    //int deleteBizGroup(List<Long> ids);
    int changeStateBizGroup(List<Long> ids, int state);

    int changePidBizGroup(List<Long> pids, Long new_pid);

    List<Map<String, Object>> selectBizGroupParentTree(List<Long> ids);

    // ver2
    List<Map<String, Object>> selectRootNode(boolean isDbRoot, Long top_group_id, String date_start, String date_end, 
        String name, String biz_reg_num);

    List<Map<String, Object>> selectBizGroupChildTree(boolean queryAll, Long pid, Long top_group_id, String date_start, String date_end, 
        String name, String biz_reg_num);

    List<Map<String, Object>> selectBizGroupTree(boolean queryAll, Long biz_group_id, String date_start, String date_end, 
        String name, String biz_reg_num);

    // get ids
    List<Long> selectBizGroupDownwardIds(Long biz_group_id);
    List<Long> selectBizGroupDownwardIdsByTerminalId(Long terminal_id);
    List<Long> selectBizGroupDownwardIdsByDeviceId(Long device_id);

    List<Long> selectBizGroupUpwardIds(Long biz_group_id);
    List<Long> selectBizGroupUpwardIdsByTerminalId(Long terminal_id);
    List<Long> selectBizGroupUpwardIdsByDeviceId(Long device_id);
}
