package nccloud.web.hrwa.pubinfo.wadataexplain.action;

import nc.vo.pubapp.AppContext;
import nc.vo.pubapp.pattern.pub.PubAppTool;
import nccloud.framework.web.processor.IRefSqlBuilder;
import nccloud.framework.web.processor.refgrid.RefQueryInfo;
import nccloud.framework.web.ui.meta.RefMeta;
import nccloud.framework.web.container.SessionContext;
import nccloud.pubitf.platform.db.SqlParameterCollection;

public class HrwaClassdevFilter implements IRefSqlBuilder {

	@Override
	public String getExtraSql(RefQueryInfo para, RefMeta meta) {
		// TODO Auto-generated method stub
	
		if("pk_country".equals(meta.getPkField()))
			return "";
		String pk_org = para.getQueryCondition().get("pk_org");
		String cuser =  SessionContext.getInstance().getClientInfo().getUserid();
		 //add by longht 增加查询过滤，按权限项目 20211220  start
		String powersql = "SELECT  classid" + 
				"  FROM wa_clspower where 1=1"
				+ "   and ( pk_subject = '"
				+ cuser + "'"
				+ " or pk_subject in ( SELECT sur.pk_role FROM sm_user_role sur where sur.cuserid = '"
				+ cuser + "') ) and pk_org = '"+pk_org+"'    and subject_type = '1' \n";
		
		
		return "  wa_waclass.class_id in("+powersql+")";

	}

	@Override
	public SqlParameterCollection getExtraSqlParameter(RefQueryInfo para, RefMeta meta) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getOrderSql(RefQueryInfo para, RefMeta meta) {
		// TODO Auto-generated method stub
		return null;
	}

}
