From 9bce48a9f30f7d80c43f43f46d40df20fcb00e15 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期五, 03 二月 2023 09:39:59 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/service/all/BaseQueryService.java | 134 +++++++++++++++++++++++++------------------- 1 files changed, 75 insertions(+), 59 deletions(-) diff --git a/src/main/java/com/lf/server/service/all/BaseQueryService.java b/src/main/java/com/lf/server/service/all/BaseQueryService.java index 40a1769..39172ba 100644 --- a/src/main/java/com/lf/server/service/all/BaseQueryService.java +++ b/src/main/java/com/lf/server/service/all/BaseQueryService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.lf.server.entity.all.RedisCacheKey; import com.lf.server.entity.ctrl.IdNameEntity; +import com.lf.server.entity.ctrl.KeyValueEntity; import com.lf.server.entity.ctrl.TabEntity; import com.lf.server.entity.data.DictEntity; import com.lf.server.entity.data.DomainEntity; @@ -14,7 +15,6 @@ import com.lf.server.mapper.all.BasicMapper; import com.lf.server.mapper.all.GeomBaseMapper; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.cache.RedisCache; import org.springframework.stereotype.Service; import java.util.HashMap; @@ -38,44 +38,6 @@ * 琛ㄥ悕Map */ private static Map<String, String> tabMap = new HashMap<String, String>(3); - - /** - * 鑾峰彇鐖禡apper - * - * @param name Mapper鍚� - * @return BaseMapper - */ - public BasicMapper getBasicMapper(String name) { - if (StringHelper.isEmpty(name)) { - return null; - } - - Object obj = ClassHelper.getBean(name.trim() + "Mapper"); - if (!(obj instanceof BasicMapper)) { - return null; - } - - return (BasicMapper) obj; - } - - /** - * 鑾峰彇绌洪棿鐖禡apper - * - * @param name Mapper鍚� - * @return GeomBaseMapper - */ - public GeomBaseMapper getGeoBaseMapper(String name) { - if (StringHelper.isEmpty(name)) { - return null; - } - - Object obj = ClassHelper.getBean(name.trim() + "Mapper"); - if (!(obj instanceof GeomBaseMapper)) { - return null; - } - - return (GeomBaseMapper) obj; - } /** * 娣诲姞杩囨护鏉′欢 @@ -110,19 +72,19 @@ /** * 鑾峰彇鍊煎璞� * - * @param value 鍊� + * @param val 鍊� * @return 瀵硅薄 */ - private Object getObjectVal(String value) { - if (StringHelper.isInteger(value)) { - return Long.parseLong(value); + private Object getObjectVal(String val) { + if (StringHelper.isInteger(val)) { + return Long.parseLong(val); } - if (StringHelper.isNumeric(value)) { - return Double.parseDouble(value); + if (StringHelper.isNumeric(val)) { + return Double.parseDouble(val); } - return value.replace("'", ""); + return val.replace("'", ""); } /** @@ -131,30 +93,36 @@ * @param wrapper QueryWrapper * @param field 瀛楁 * @param express 琛ㄨ揪寮� - * @param value 鍊� + * @param val 鍊� */ - private void addWrapper(QueryWrapper wrapper, String field, String express, Object value) { + private void addWrapper(QueryWrapper wrapper, String field, String express, Object val) { + if (StringHelper.isDate(val.toString())) { + wrapper.apply(String.format("%s %s '%s'", field, express, val)); + return; + } + switch (express) { case "like": - wrapper.like(field, value); + wrapper.like(field, val); break; case ">": - wrapper.gt(field, value); + wrapper.gt(field, val); break; case ">=": - wrapper.ge(field, value); + wrapper.ge(field, val); break; case "<>": - wrapper.ne(field, value); + case "!=": + wrapper.ne(field, val); break; case "=": - wrapper.eq(field, value); + wrapper.eq(field, val); break; case "<": - wrapper.lt(field, value); + wrapper.lt(field, val); break; case "<=": - wrapper.le(field, value); + wrapper.le(field, val); break; default: break; @@ -174,7 +142,9 @@ wkt = AesHelper.decrypt(wkt); Integer srid = getSrid((GeomBaseMapper) basicMapper); - wrapper.apply(String.format("ST_Intersects(ST_PolygonFromText('%s', %d), geom)", wkt, srid)); + if (null != srid) { + wrapper.apply(String.format("ST_Intersects(ST_PolygonFromText('%s', %d), geom)", wkt, srid)); + } } } @@ -184,7 +154,7 @@ * @param basicMapper 绌洪棿鍩虹Mapper * @return SRID */ - private Integer getSrid(GeomBaseMapper basicMapper) { + public Integer getSrid(GeomBaseMapper basicMapper) { String tab = getTabName(basicMapper); String key = RedisCacheKey.sridKey(tab); @@ -207,7 +177,7 @@ * @param basicMapper Mapper * @return 琛ㄥ悕 */ - public String getTabName(BasicMapper basicMapper) { + public static String getTabName(BasicMapper basicMapper) { String className = ClassHelper.getClassName(basicMapper); if (tabMap.containsKey(className)) { return tabMap.get(className); @@ -222,7 +192,7 @@ * @param className Mapper绫诲悕 * @return 琛ㄥ悕 */ - private String getTabName(String className) { + private static String getTabName(String className) { Class clazz = ClassHelper.getEntityClass(className); if (clazz == null) { return null; @@ -258,6 +228,20 @@ } @Override + public Integer selectTabsForCount(String tab) { + tab = StringHelper.getLikeStr(tab); + + return baseQueryMapper.selectTabsForCount(tab); + } + + @Override + public List<TabEntity> selectTabsByPage(String tab, Integer limit, Integer offset) { + tab = StringHelper.getLikeStr(tab); + + return baseQueryMapper.selectTabsByPage(tab, limit, offset); + } + + @Override public List<DictEntity> selectFields(String ns, String tab) { return baseQueryMapper.selectFields(ns, tab); } @@ -266,4 +250,36 @@ public List<DomainEntity> selectDomains(String ns, String tab) { return baseQueryMapper.selectDomains(ns, tab); } + + @Override + public String selectRoute(double x1, double y1, double x2, double y2) { + return baseQueryMapper.selectRoute(x1, y1, x2, y2); + } + + @Override + public List<KeyValueEntity> selectLocation(String wkt) { + return baseQueryMapper.selectLocation(wkt); + } + + @Override + public List<KeyValueEntity> selectBaseType() { + return baseQueryMapper.selectBaseType(); + } + + @Override + public List<KeyValueEntity> selectBusinessType() { + return baseQueryMapper.selectBusinessType(); + } + + @Override + public List<KeyValueEntity> selectProject() { + return baseQueryMapper.selectProject(); + } + + @Override + public List<DictEntity> selectTabCount(String name, String dirs, Integer depid) { + name = StringHelper.getLikeStr2(name); + + return baseQueryMapper.selectTabCount(name, dirs, depid); + } } -- Gitblit v1.9.3