/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved. <a>http://www.crunii.com</a>
 */
package com.crunii.micro.platform.jdbc;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.crunii.micro.common.constants.CommonConstants;
import com.crunii.micro.domain.common.jdbc.BaseJdbcTemplate;
import com.crunii.micro.domain.common.jdbc.BaseNPJdbcTemplate;
import com.crunii.micro.domain.entity.main.TsmUrl;

import lombok.extern.slf4j.Slf4j;

/**
 * @author 田平 create 2017年8月11日下午12:44:04
 */
@Slf4j
@Repository
public class LogUrlJdbcDao {

	@Resource(name = "mainJT")
	protected BaseJdbcTemplate JT;

	@Resource(name = "mainNPJT")
	protected BaseNPJdbcTemplate NPJT;

	private static final String checkLogUrlSql = "select count(*) from tsm_url where url_path=? and log_flag=? and state=1 ";

	private static final String getAntUrlsSql = "select * from tsm_url where url_type=? and log_flag=? and state=1";

	public boolean checkLogUrl(String url) {
		int count = JT.queryForInt(checkLogUrlSql, url.trim(), CommonConstants.LOG_FLAG_YES);
		return count > 0 ? true : false;
	}

	public List<TsmUrl> getAntUrls() {
		return JT.queryForBeans(TsmUrl.class, getAntUrlsSql, CommonConstants.URL_TYPE_ANT, CommonConstants.LOG_FLAG_YES);
	}

}
