package com.sifang.modules.supply.warehouse.dao;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.sifang.modules.supply.warehouse.entity.CrmFittingStockUpApplyDetail;
import com.sifang.modules.sys.common.persistence.BaseDao;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class CrmFittingStockUpApplyDetailDao extends BaseDao<CrmFittingStockUpApplyDetail> {

    public void deleteDetail(String mainId){
        Db.update(" DELETE FROM `crm_fitting_stock_up_apply_detail` WHERE main_id=? and status='1' ",mainId);
    }

    public List<Record> getFittingApplyDetail(String id){
        String sql=" SELECT d.id,d.main_id,d.material_id,d.material_code,d.material_type,d.material_type_id,d.remark,d.amount" +
                ",d.material_spec,IFNULL(m.unit_name,'') as unitName,IFNULL(m.material_brand,'') as material_brand  " +
                "FROM `crm_fitting_stock_up_apply_detail` d left join crm_supply_material m on m.id=d.material_id" +
                " WHERE d.main_id=? and d.status='1' ";
        return Db.find(sql,id);
    }
}
