package com.product.admin.service;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import com.product.admin.config.SystemCode;
|
import com.product.core.cache.DataPoolRefreshCache;
|
import com.product.core.config.CoreConst;
|
import com.product.core.dao.BaseDao;
|
import com.product.core.entity.DataTableEntity;
|
import com.product.core.exception.BaseException;
|
import com.product.core.service.support.AbstractBaseService;
|
import com.product.util.BaseUtil;
|
|
@Component
|
public class SystemCacheService extends AbstractBaseService {
|
|
@Autowired
|
private BaseDao baseDao;
|
|
public void refreshCache(String[] tableNames) throws BaseException {
|
if (tableNames == null || tableNames.length == 0) {
|
DataTableEntity listTable = baseDao.listTable(CoreConst.PRODUCT_SYS_CACHE_CONFIG);
|
if (BaseUtil.dataTableIsEmpty(listTable)) {
|
throw new BaseException(SystemCode.SYSTEM_CACHE_TABLE_FOR_EMPTY.getValue(),
|
SystemCode.SYSTEM_CACHE_TABLE_FOR_EMPTY.getText(), this.getClass(), "refreshCache");
|
}
|
for (int i = 0; i < listTable.getRows(); i++) {
|
|
|
DataPoolRefreshCache.getInstance().put(listTable.getString(i, "table_name"));
|
|
|
}
|
} else {
|
for (int i = 0; i < tableNames.length; i++) {
|
DataPoolRefreshCache.getInstance().put(tableNames[i]);
|
}
|
}
|
}
|
}
|