package com.sifang.modules.sunshine.SystemSetting.dao;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.sifang.modules.sunshine.SystemSetting.entity.CrmPlantForm;
import com.sifang.modules.sunshine.SystemSetting.entity.CrmProjectTypeReference;
import com.sifang.modules.sunshine.SystemSetting.entity.ProjectRentVariable;
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;


@Repository
public class ProjectTypeReferenceDao extends BaseDao<CrmProjectTypeReference> {

    public List<Record> getCompanyAllData(String wayId){
        StringBuffer sf = new StringBuffer();
        sf.append("SELECT p.* FROM crm_project_type_reference p WHERE p.`install_way_id`=? ");
        return Db.find(sf.toString(),wayId);
    }

    public void deleteVariable(String wayId){
        SQLQuery sqlQuery = getSession().createSQLQuery("DELETE FROM crm_project_type_reference WHERE install_way_id=:wayId");
        sqlQuery.setParameter("wayId", wayId);
        sqlQuery.executeUpdate();
    }

    public List<CrmProjectTypeReference> getProjectReference(String installWayId){
        Query query = getSession().createQuery("from CrmProjectTypeReference where installWayId=:installWayId ");
        query.setParameter("installWayId", installWayId);
        List<CrmProjectTypeReference> list=query.list();
        return list;
    }


}
