package com.sifang.modules.insurance.dao;

import com.sifang.modules.insurance.entity.CrmCustomerEntryInsuranceInsured;
import com.sifang.modules.sys.common.persistence.BaseDao;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * @author DQChen
 * @date 2024-01-19 10:00
 */
@Repository
public class CustomerEntryInsuranceInsuredDao extends BaseDao<CrmCustomerEntryInsuranceInsured> {

    public void deleteByInsuranceId(String insuranceId) {
        SQLQuery sqlQuery = getSession().createSQLQuery("delete from crm_customer_entry_insurance_insured where insurance_id=:id");
        sqlQuery.setParameter("id", insuranceId);
        sqlQuery.executeUpdate();
    }

    @SuppressWarnings("unchecked")
    public List<CrmCustomerEntryInsuranceInsured> findByInsuranceId(String insuranceId) {
        Query sqlQuery = getSession().createQuery("from CrmCustomerEntryInsuranceInsured where insuranceId=:id");
        sqlQuery.setParameter("id", insuranceId);
        return sqlQuery.list();
    }

}
