package com.sky.ioc.mapper.person;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sky.ioc.entity.domain.person.Person;
import com.sky.ioc.entity.params.scene.DoorAccessParam;
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;
import java.util.Map;

@Mapper
public interface PersonMapper extends BaseMapper<Person> {

    @Update("<script>" +
            " update person set is_del = 1,update_time = now() " +
            " where id in (<foreach collection='ids' item='id' index='no' separator=','>#{id}</foreach>) "

            + "</script>")
    Integer batchDelByIds(@Param("ids") List<Integer> ids);


    @Select("<script>" +
            "SELECT * " +
            "from  person " +
            "where is_del=0 " +
            "<if test='name!=null and name!=\"\"'>" +
            " and name like #{name} " +
            "</if>" +
            "<if test='companyName!=null and companyName!=\"\" '>" +
            " and company_name like #{companyName} " +
            "</if>" +
            "<if test='deptName!=null and deptName!=\"\" '>" +
            " and dept_name like #{deptName} " +
            "</if>" +
            "<if test='type!=null and type>=0 '>" +
            " and type = #{type} " +
            "</if>" +
            "<if test='status!=null and status>=0 '>" +
            " and status = #{status} " +
            "</if>" +
            "<if test='phone!=null and phone!=\"\" '>" +
            " and phone like #{phone} " +
            "</if>" +
            "ORDER BY id " +
            "</script>")
    List<Person> pageList(@Param("name") String name,
                          @Param("companyName") String companyName,
                          @Param("deptName") String deptName,
                          @Param("type") Integer type,
                          @Param("status") Integer status,
                          @Param("phone")String phone);
}
