提交 edcc1116 编写于 作者: Z zhuangqian

update

上级 d580d7fb
......@@ -32,15 +32,16 @@ import com.smallchill.core.interfaces.IMeta;
import com.smallchill.core.meta.MetaIntercept;
import com.smallchill.core.plugins.dao.Blade;
import com.smallchill.core.plugins.dao.Db;
import com.smallchill.core.service.CurdService;
import com.smallchill.core.toolbox.Func;
import com.smallchill.core.toolbox.Paras;
import com.smallchill.core.toolbox.ajax.AjaxResult;
import com.smallchill.core.toolbox.kit.JsonKit;
import com.smallchill.core.toolbox.kit.StrKit;
import com.smallchill.core.toolbox.support.Singleton;
import com.smallchill.system.service.CurdService;
public abstract class CurdController<M> extends BaseController {
@Autowired
CurdService service;
......
......@@ -238,6 +238,30 @@ public class Db {
return getDbManager().selectList(sqlTemplate, param, ac, intercept);
}
/**
* 根据缓存找一条数据
* @param cacheName
* @param key
* @param sqlTemplate
* @param paras
* @return Map
*/
public static Map selectOneByCache(String cacheName, String key, String sqlTemplate, Object paras){
return getDbManager().selectOneByCache(cacheName, key, sqlTemplate, paras);
}
/**
* 根据缓存找多条数据
* @param cacheName
* @param key
* @param sqlTemplate
* @param paras
* @return List<Map>
*/
public static List<Map> selectListByCache(String cacheName, String key, String sqlTemplate, Object paras){
return getDbManager().selectListByCache(cacheName, key, sqlTemplate, paras);
}
/************ ↑↑↑ ******** 通用 ********* ↑↑↑ ****************/
/**
......
......@@ -25,10 +25,12 @@ import org.beetl.sql.core.SQLResult;
import com.smallchill.core.aop.AopContext;
import com.smallchill.core.constant.Cst;
import com.smallchill.core.interfaces.ILoader;
import com.smallchill.core.interfaces.IQuery;
import com.smallchill.core.plugins.connection.ConnectionPlugin;
import com.smallchill.core.toolbox.Func;
import com.smallchill.core.toolbox.Paras;
import com.smallchill.core.toolbox.kit.CacheKit;
import com.smallchill.core.toolbox.kit.StrKit;
import com.smallchill.core.toolbox.support.BladePage;
......@@ -337,6 +339,42 @@ public class DbManager {
return rst;
}
/**
* 根据缓存找一条数据
* @param cacheName
* @param key
* @param sqlTemplate
* @param paras
* @return Map
*/
public Map selectOneByCache(String cacheName, String key, String sqlTemplate, Object paras){
final String _sqlTemplate = sqlTemplate;
final Object _paras = paras;
return CacheKit.get(cacheName, key, new ILoader() {
public Object load() {
return selectOne(_sqlTemplate, _paras);
}
});
}
/**
* 根据缓存找多条数据
* @param cacheName
* @param key
* @param sqlTemplate
* @param paras
* @return List<Map>
*/
public List<Map> selectListByCache(String cacheName, String key, String sqlTemplate, Object paras){
final String _sqlTemplate = sqlTemplate;
final Object _paras = paras;
return CacheKit.get(cacheName, key, new ILoader() {
public Object load() {
return selectList(_sqlTemplate, _paras);
}
});
}
/************ ↑↑↑ ******** 通用 ********* ↑↑↑ ****************/
/**
......
/**
* Copyright (c) 2015-2016, Chill Zhuang 庄骞 (smallchill@163.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.smallchill.core.service;
import com.smallchill.core.interfaces.ICache;
public interface CacheService extends ICache{
}
/**
* Copyright (c) 2015-2016, Chill Zhuang 庄骞 (smallchill@163.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.smallchill.core.service.impl;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.smallchill.core.interfaces.ILoader;
import com.smallchill.core.plugins.dao.Blade;
import com.smallchill.core.plugins.dao.Db;
import com.smallchill.core.service.CacheService;
import com.smallchill.core.toolbox.kit.CacheKit;
@Service
public class CacheServiceImpl implements CacheService{
public Map<String, Object> findOne(String cacheName, String key, final String sql) {
return CacheKit.get(cacheName, key, new ILoader() {
@Override
public Object load() {
return Db.selectOne(sql);
}
});
}
public Map<String, Object> findOne(String cacheName, String key,
final String sql, final Object modelOrMap) {
return CacheKit.get(cacheName, key, new ILoader() {
@Override
public Object load() {
return Db.selectOne(sql, modelOrMap);
}
});
}
public Map<String, Object> findOneBySqlId(String cacheName, String key,
final String sqlId) {
return CacheKit.get(cacheName, key, new ILoader() {
@Override
public Object load() {
return Blade.dao().select(sqlId, Map.class, null);//selectOneBySqlId(sqlId, null);
}
});
}
public Map<String, Object> findOneBySqlId(String cacheName, String key,
final String sqlId, final Object modelOrMap) {
return CacheKit.get(cacheName, key, new ILoader() {
@Override
public Object load() {
return Blade.dao().select(sqlId, Map.class, modelOrMap);
}
});
}
public List<Map<String, Object>> find(String cacheName, String key,
final String sql) {
return CacheKit.get(cacheName, key, new ILoader() {
@Override
public Object load() {
return Db.selectList(sql);
}
});
}
public List<Map<String, Object>> find(String cacheName, String key,
final String sql, final Object modelOrMap) {
return CacheKit.get(cacheName, key, new ILoader() {
@Override
public Object load() {
return Db.selectList(sql, modelOrMap);
}
});
}
public List<Map<String, Object>> findBySqlId(String cacheName, String key,
final String sqlId) {
return CacheKit.get(cacheName, key, new ILoader() {
@Override
public Object load() {
return Blade.dao().select(sqlId, Map.class, null);
}
});
}
public List<Map<String, Object>> findBySqlId(String cacheName, String key,
final String sqlId, final Object modelOrMap) {
return CacheKit.get(cacheName, key, new ILoader() {
@Override
public Object load() {
return Blade.dao().select(sqlId, Map.class, modelOrMap);
}
});
}
}
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.smallchill.core.service;
package com.smallchill.system.service;
import com.smallchill.core.base.controller.BladeController;
import com.smallchill.core.meta.MetaIntercept;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.smallchill.core.service.impl;
package com.smallchill.system.service.impl;
import org.springframework.stereotype.Service;
......@@ -21,9 +21,9 @@ import com.smallchill.core.aop.AopContext;
import com.smallchill.core.base.controller.BladeController;
import com.smallchill.core.meta.MetaIntercept;
import com.smallchill.core.plugins.dao.Blade;
import com.smallchill.core.service.CurdService;
import com.smallchill.core.toolbox.Paras;
import com.smallchill.core.toolbox.grid.GridManager;
import com.smallchill.system.service.CurdService;
@Service
public class CurdServiceImpl implements CurdService {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册