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

import com.jfinal.plugin.activerecord.Db;
import com.sifang.modules.sunshine.SystemSetting.entity.CrmProjectCompanyPcd;
import com.sifang.modules.sunshine.SystemSetting.entity.ProjectPcd;
import com.sifang.modules.sys.common.persistence.BaseDao;
import com.sifang.modules.sys.common.persistence.Parameter;
import com.sifang.modules.sys.util.SqlBuilder;
import org.hibernate.SQLQuery;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public class CrmProjectCompanyPcdDao extends BaseDao<CrmProjectCompanyPcd> {



    public void deleteInfoById(String companyId) {
        SQLQuery sqlQuery = getSession().createSQLQuery("DELETE FROM crm_project_company_pcd WHERE company_id=:p1");
        sqlQuery.setParameter("p1", companyId);
        sqlQuery.executeUpdate();
    }


    public List<ProjectPcd> findListByProjectId(String companyId) {
        return find("FROM CrmProjectCompanyPcd WHERE companyId = :p1 AND status = '0' ORDER BY createTime,sort", new Parameter(companyId));
    }

}
