| | |
| | | <module>se-common</module> |
| | | <module>se-gateway</module> |
| | | <module>se-system</module> |
| | | <module>se-collect</module> |
| | | <module>se-discover</module> |
| | | <module>se-publish</module> |
| | | </modules> |
| | | <packaging>pom</packaging> |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.terra.collect.config; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.DbType; |
| | | import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer; |
| | | import com.baomidou.mybatisplus.core.MybatisConfiguration; |
| | | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
| | | import com.terra.collect.extend.CustomizedSqlInjector; |
| | | import org.apache.ibatis.type.JdbcType; |
| | | import org.mybatis.spring.annotation.MapperScan; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.transaction.annotation.EnableTransactionManagement; |
| | | |
| | | /** |
| | | * Mybatis-Pluså页é
ç½® |
| | | * @author WWW |
| | | */ |
| | | @EnableTransactionManagement |
| | | @Configuration |
| | | @MapperScan("com.terra.system.mapper") |
| | | public class MybatisPlusConfig { |
| | | /** |
| | | * æ°çå页æä»¶,ä¸ç¼åäºç¼éµå¾ªmybatisçè§å,éè¦è®¾ç½® |
| | | * MybatisConfiguration#useDeprecatedExecutor = false |
| | | * é¿å
ç¼ååºç°é®é¢(è¯¥å±æ§ä¼å¨æ§æä»¶ç§»é¤åä¸åç§»é¤) |
| | | */ |
| | | @Bean |
| | | public MybatisPlusInterceptor mybatisPlusInterceptor() { |
| | | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |
| | | interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.POSTGRE_SQL)); |
| | | return interceptor; |
| | | } |
| | | |
| | | @Bean |
| | | public ConfigurationCustomizer configurationCustomizer() { |
| | | return new ConfigurationCustomizer() { |
| | | @Override |
| | | public void customize(MybatisConfiguration configuration) { |
| | | configuration.setCacheEnabled(true); |
| | | configuration.setMapUnderscoreToCamelCase(true); |
| | | configuration.setCallSettersOnNulls(true); |
| | | configuration.setJdbcTypeForNull(JdbcType.NULL); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | @Bean |
| | | public CustomizedSqlInjector customizedSqlInjector() { |
| | | return new CustomizedSqlInjector(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.terra.collect.entity.all; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * éææ°æ®ç±» |
| | | * @author WWW |
| | | */ |
| | | public class StaticData { |
| | | /** |
| | | * æéæé¤è·¯å¾ï¼/proxyï¼è¦æ±å
¨é¨å°å |
| | | */ |
| | | public static String[] EXCLUDE_PATH = new String[]{"/sign/", "/perms/", "/fmeit/", "/crds/", "/floatserver/", "/wmts/select", "/onemap/", "/swagger", "/error"}; |
| | | |
| | | public final static int I1 = 1; |
| | | |
| | | public final static int I2 = 2; |
| | | |
| | | public final static int FOUR = 4; |
| | | |
| | | public final static int I5 = 5; |
| | | |
| | | public final static int NINE = 9; |
| | | |
| | | public final static int I10 = 10; |
| | | |
| | | public final static int SIXTEEN = 16; |
| | | |
| | | public final static int TWO_HUNDRED = 200; |
| | | |
| | | public final static int I100000 = 100000; |
| | | |
| | | public final static int I1000000 = 1000000; |
| | | |
| | | public static final double D90 = 90.0; |
| | | |
| | | public static final double D100 = 100.0; |
| | | |
| | | public static final double D1024 = 1024.0; |
| | | |
| | | public static final double D1050 = 1050.0; |
| | | |
| | | public static final int I12 = 12; |
| | | |
| | | public static final int I23 = 23; |
| | | |
| | | public static final int I24 = 24; |
| | | |
| | | public static final int I31 = 31; |
| | | |
| | | public static final int I50 = 50; |
| | | |
| | | public static final int I60 = 60; |
| | | |
| | | public static final int I90 = 90; |
| | | |
| | | public static final int I90_NEG = -90; |
| | | |
| | | public final static int I100 = 100; |
| | | |
| | | public final static int I120 = 120; |
| | | |
| | | public static final int I180 = 180; |
| | | |
| | | public static final int I180_NEG = -180; |
| | | |
| | | public static final int I1000 = 1000; |
| | | |
| | | public static final int I2050 = 2050; |
| | | |
| | | public static final int I4326 = 4326; |
| | | |
| | | public static final int I4490 = 4490; |
| | | |
| | | public final static String S1 = "1"; |
| | | |
| | | public final static String EQ = "="; |
| | | |
| | | public final static String POINT = "."; |
| | | |
| | | public final static String COMMA = ","; |
| | | |
| | | public final static String TILDE = "~"; |
| | | |
| | | public final static String SINGLE_QUOTES = "'"; |
| | | |
| | | public final static String BBOREHOLE = "bborehole"; |
| | | |
| | | public final static String SLASH = "/"; |
| | | |
| | | public final static String IN = "in"; |
| | | |
| | | public final static String DWG = "dwg"; |
| | | |
| | | public final static String ZIP = ".zip"; |
| | | |
| | | public final static String XLS = ".xls"; |
| | | |
| | | public final static String XLSX = ".xlsx"; |
| | | |
| | | public final static String MDB = ".mdb"; |
| | | |
| | | public final static String KML = ".kml"; |
| | | |
| | | public final static String SHP = ".shp"; |
| | | |
| | | public final static String NGDB = "gdb"; |
| | | |
| | | public final static String GDB = ".gdb"; |
| | | |
| | | public final static String JPG = ".jpg"; |
| | | |
| | | public final static String IMG = ".img"; |
| | | |
| | | public final static String MPT = ".mpt"; |
| | | |
| | | public final static String D3DML = ".3dml"; |
| | | |
| | | public final static String TIF = ".tif"; |
| | | |
| | | public final static String TIFF = ".tiff"; |
| | | |
| | | public final static String LAS = ".las"; |
| | | |
| | | public final static String OSGB = ".osgb"; |
| | | |
| | | public static String ADMIN = "admin"; |
| | | |
| | | public final static String SYS_META = "sysmeta"; |
| | | |
| | | public final static String VERSION = "1.0.0"; |
| | | |
| | | public final static String TOKEN_KEY = "token"; |
| | | |
| | | public final static String TOKEN_COOKIE_KEY = "token"; |
| | | |
| | | public final static String TEXT_ENCODER = "UTF-8"; |
| | | |
| | | public final static String CHECK_MAIN = "checkMain"; |
| | | |
| | | public final static String OBJECT = "java.lang.Object"; |
| | | |
| | | public final static String DRUID_COOKIE_KEY = "JSESSIONID"; |
| | | |
| | | public final static String YES = "YES"; |
| | | |
| | | public final static String NO = "NO"; |
| | | |
| | | public final static String ROUTE = "线路"; |
| | | |
| | | public final static String CROSSING = "ç©¿è·¨è¶"; |
| | | |
| | | public final static String LINESTRING = "LINESTRING"; |
| | | |
| | | public final static String MULTILINESTRING = "MULTILINESTRING"; |
| | | |
| | | public final static String POLYGON = "POLYGON"; |
| | | |
| | | public final static String MULTIPOLYGON = "MULTIPOLYGON"; |
| | | |
| | | public final static String MULTICURVE = "MULTICURVE"; |
| | | |
| | | public final static String COMPOUNDCURVE = "COMPOUNDCURVE"; |
| | | |
| | | public final static String CGCS2000 = "CGCS2000"; |
| | | |
| | | public static final String NO_FILE = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.NOT_FOUND, "æä»¶æ¾ä¸å°")); |
| | | |
| | | /** |
| | | * 16è¿å¶ |
| | | */ |
| | | public static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; |
| | | |
| | | /** |
| | | * æ
æ ¼æ°æ®æ©å±å |
| | | */ |
| | | public final static List<String> RASTER_EXT = new ArrayList<>(Arrays.asList(".img", ".tif", ".tiff", ".jpg", ".jp2")); |
| | | |
| | | /** |
| | | * å¯ç æ£åè¡¨è¾¾å¼ |
| | | */ |
| | | public final static String PWD_REG = "^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W!@#$%^&*`~()\\-_+=,.?;<>]+$)(?![a-z0-9]+$)(?![a-z\\W!@#$%^&*`~()\\-_+=,.?;<>]+$)(?![0-9\\W!@#$%^&*`~()\\-_+=,.?;<>]+$)[a-zA-Z0-9\\W!@#$%^&*`~()\\-_+=,.?;<>]{12,20}$"; |
| | | |
| | | /** |
| | | * MPTæä»¶æ©å±å |
| | | */ |
| | | public final static List<String> MPT_EXT = new ArrayList<>(Arrays.asList(".midx", ".strmi", ".ei.midx", ".ei.mpt", ".ei.strmi")); |
| | | |
| | | /** |
| | | * JPGæä»¶æ©å±å |
| | | */ |
| | | public final static List<String> JPG_EXT = new ArrayList<>(Arrays.asList(".jpg.aux.xml", ".jpg.ovr", ".jpg.xml", ".jgw", ".prj")); |
| | | |
| | | /** |
| | | * JP2æä»¶æ©å±å |
| | | */ |
| | | public final static List<String> JP2_EXT = new ArrayList<>(Arrays.asList(".jp2.aux.xml", ".jp2.ovr", ".jp2.xml", ".jgw", ".prj", ".jp2.html", ".jp2.txt")); |
| | | |
| | | /** |
| | | * IMGæä»¶æ©å±å |
| | | */ |
| | | public final static List<String> IMG_EXT = new ArrayList<>(Arrays.asList(".rrd", ".img.aux.xml", ".hdr", ".img.enp", ".img.xml")); |
| | | |
| | | /** |
| | | * TIFæä»¶æ©å±å |
| | | */ |
| | | public final static List<String> TIF_EXT = new ArrayList<>(Arrays.asList(".prj", ".tfw", ".aux", ".tif.ovr", ".tif.aux.xml", ".tif.xml")); |
| | | |
| | | /** |
| | | * TIFFæä»¶æ©å±å |
| | | */ |
| | | public final static List<String> TIFF_EXT = new ArrayList<>(Arrays.asList(".prj", ".tfw", ".aux", ".tiff.ovr", ".tiff.aux.xml", ".tiff.xml")); |
| | | |
| | | /** |
| | | * SHPæä»¶æ©å±å |
| | | */ |
| | | public final static List<String> SHP_EXT = new ArrayList<>(Arrays.asList(".shx", ".dbf", ".prj", ".cpg")); |
| | | |
| | | /** |
| | | * Mapperæé¤æ©å±å |
| | | */ |
| | | public final static List<String> MAPPER_EXCLUDE_EXT = new ArrayList<>(Arrays.asList(".jpg.aux.xml", ".jpg.xml", ".jp2.aux.xml", ".jp2.xml", ".jp2.html", ".jp2.txt", ".img.aux.xml", ".img.xml", ".tif.aux.xml", ".tif.xml", ".tiff.aux.xml", ".tiff.xml", ".shp.xml", ".ecw.xml", "ecw.aux.xml")); |
| | | |
| | | /** |
| | | * æææä»¶æ©å±å |
| | | */ |
| | | public final static List<String> ALL_EXTENSION = new ArrayList<>(Arrays.asList(".txt", ".xml", ".pdf", ".xls", ".xlsx", ".doc", ".docx", ".ppt", ".pptx", ".shp", ".gdb", ".mdb", ".dwg", ".las", ".laz", ".cpt", ".mpt", ".ei.mpt", ".fly", ".efb", ".g3d", ".fbx", ".obj", ".3dm", ".3dml", ".osgb", ".rvt", ".ifc", ".jpg", ".jp2", ".png", ".img", ".tif", ".tiff", ".dem", ".bmp", ".gif", ".rmvb", ".rm", ".mp3", ".mp4", ".avi", ".wma", ".wmv", ".7z", ".rar", ".zip", ".lz", ".kml")); |
| | | |
| | | /** |
| | | * æå
¥æé¤å段 |
| | | */ |
| | | public final static List<String> INSERT_EXCLUDE_FIELDS = new ArrayList<>(Arrays.asList("gid", "objectid", "updateuser", "updatetime", "shape_leng", "shape_area", "serialVersionUID", "dirName", "depName", "verName", "createName", "updateName")); |
| | | |
| | | /** |
| | | * æ´æ°æé¤å段 |
| | | */ |
| | | public final static List<String> UPDATE_EXCLUDE_FIELDS = new ArrayList<>(Arrays.asList("objectid", "createuser", "createtime", "shape_leng", "shape_area", "serialVersionUID", "dirName", "depName", "verName", "createName", "updateName")); |
| | | |
| | | /** |
| | | * 读åæé¤å段 |
| | | */ |
| | | public final static List<String> READ_EXCLUDE_FIELDS = new ArrayList<>(Arrays.asList("gid", "eventid", "parentid", "objectid", "dirid", "depid", "verid", "createtime", "createuser", "updateuser", "updatetime", "shape_leng", "shape_area", "serialversionuid", "dirname", "depname", "vername", "createname", "updatename")); |
| | | |
| | | /** |
| | | * MDBæé¤å段 |
| | | */ |
| | | public final static List<String> MDB_EXCLUDE_FIELDS = new ArrayList<>(Arrays.asList("Shape", "SHAPE_LENG", "Shape_Length", "Shape_Area", "OBJECTID_1")); |
| | | |
| | | /** |
| | | * æ ç»Shpæé¤å段 |
| | | */ |
| | | public final static List<String> MARK_EXCLUDE_FIELDS = new ArrayList<>(Arrays.asList("wkt", "geom", "objectid", "shape_leng", "shape_area", "serialVersionUID", "dirName", "depName", "verName", "createName", "updateName")); |
| | | |
| | | /** |
| | | * GDBæé¤å段 |
| | | */ |
| | | public final static List<String> GDB_EXCLUDE_FIELDS = new ArrayList<>(Arrays.asList("geom", "objectid", "shape_leng", "shape_area", "serialVersionUID", "dirName", "depName", "verName", "createName", "updateName")); |
| | | |
| | | /** |
| | | * 管线åæè¡¨åéå |
| | | */ |
| | | public final static List<String> PIPE_ANALYSIS_TABS = new ArrayList<>(Arrays.asList("bd.dlg_25w_hydl", "bd.dlg_25w_lrdl", "bd.dlg_25w_lrrl", "bd.dlg_25w_hyda")); |
| | | |
| | | /** |
| | | * 管线æé¤å段 |
| | | */ |
| | | public final static List<String> PIPE_EXCLUDE_FIELDS = new ArrayList<>(Arrays.asList("serialVersionUID", "tabs", "pwd", "gid", "wkt")); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.terra.collect.extend; |
| | | |
| | | import com.baomidou.mybatisplus.core.injector.AbstractMethod; |
| | | import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector; |
| | | import com.baomidou.mybatisplus.core.metadata.TableInfo; |
| | | import com.terra.collect.extend.UpdateBatchMethod; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * èªå®ä¹æ¹æ³SQL注å
¥å¨ |
| | | * @author WWW |
| | | */ |
| | | public class CustomizedSqlInjector extends DefaultSqlInjector { |
| | | /** |
| | | * 妿åªéå¢å æ¹æ³ï¼ä¿çmybatis plusèªå¸¦æ¹æ³ï¼ |
| | | * å¯ä»¥å
è·åsuper.getMethodList()ï¼åæ·»å add |
| | | */ |
| | | @Override |
| | | public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) { |
| | | List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo); |
| | | methodList.add(new InsertBatchMethod()); |
| | | methodList.add(new UpdateBatchMethod()); |
| | | |
| | | return methodList; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.terra.collect.extend; |
| | | |
| | | import com.baomidou.mybatisplus.core.injector.AbstractMethod; |
| | | import com.baomidou.mybatisplus.core.metadata.TableFieldInfo; |
| | | import com.baomidou.mybatisplus.core.metadata.TableInfo; |
| | | import com.terra.collect.entity.all.StaticData; |
| | | import org.apache.ibatis.executor.keygen.NoKeyGenerator; |
| | | import org.apache.ibatis.mapping.MappedStatement; |
| | | import org.apache.ibatis.mapping.SqlSource; |
| | | |
| | | /** |
| | | * æ¹éæå
¥æ¹æ³ |
| | | * @author WWW |
| | | */ |
| | | @SuppressWarnings("ALL") |
| | | public class InsertBatchMethod extends AbstractMethod { |
| | | /** |
| | | * insert into user(id, name, age) values (1, "a", 17), (2, "b", 18); |
| | | * <script> |
| | | * insert into user(id, name, age) values |
| | | * <foreach collection="list" item="item" index="index" open="(" separator="),(" close=")"> |
| | | * #{item.id}, #{item.name}, #{item.age} |
| | | * </foreach> |
| | | * </script> |
| | | */ |
| | | @Override |
| | | public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) { |
| | | final String sql = "<script>insert into %s %s values %s</script>"; |
| | | final String fieldSql = prepareFieldSql(tableInfo); |
| | | final String valueSql = prepareValuesSql(tableInfo); |
| | | final String sqlResult = String.format(sql, tableInfo.getTableName(), fieldSql, valueSql); |
| | | |
| | | SqlSource sqlSource = languageDriver.createSqlSource(configuration, sqlResult, modelClass); |
| | | |
| | | // 第ä¸ä¸ªåæ°å¿
é¡»åRootMapperçèªå®ä¹æ¹æ³åä¸è´ |
| | | return this.addInsertMappedStatement(mapperClass, modelClass, "insertBatch", sqlSource, new NoKeyGenerator(), null, null); |
| | | } |
| | | |
| | | private String prepareFieldSql(TableInfo tableInfo) { |
| | | StringBuilder fieldSql = new StringBuilder(); |
| | | // fieldSql.append(tableInfo.getKeyColumn()).append(",") |
| | | // tableInfo.getFieldList().forEach(x -> fieldSql.append(x.getColumn()).append(",")) |
| | | for (TableFieldInfo f : tableInfo.getFieldList()) { |
| | | if (StaticData.INSERT_EXCLUDE_FIELDS.contains(f.getProperty())) { |
| | | continue; |
| | | } |
| | | |
| | | fieldSql.append(f.getColumn()).append(","); |
| | | } |
| | | |
| | | fieldSql.delete(fieldSql.length() - 1, fieldSql.length()); |
| | | fieldSql.insert(0, "("); |
| | | fieldSql.append(")"); |
| | | |
| | | return fieldSql.toString(); |
| | | } |
| | | |
| | | private String prepareValuesSql(TableInfo tableInfo) { |
| | | final StringBuilder valueSql = new StringBuilder(); |
| | | valueSql.append("<foreach collection=\"list\" item=\"item\" index=\"index\" open=\"(\" separator=\"),(\" close=\")\">"); |
| | | // valueSql.append("#{item.").append(tableInfo.getKeyProperty()).append("},") |
| | | // tableInfo.getFieldList().forEach(x -> valueSql.append("#{item.").append(x.getProperty()).append("},")) |
| | | for (TableFieldInfo f : tableInfo.getFieldList()) { |
| | | if (StaticData.INSERT_EXCLUDE_FIELDS.contains(f.getProperty())) { |
| | | continue; |
| | | } |
| | | |
| | | valueSql.append("geom".equals(f.getProperty()) ? "${item." : "#{item.").append(f.getProperty()).append("},"); |
| | | } |
| | | |
| | | valueSql.delete(valueSql.length() - 1, valueSql.length()); |
| | | valueSql.append("</foreach>"); |
| | | |
| | | return valueSql.toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.terra.collect.extend; |
| | | |
| | | import com.baomidou.mybatisplus.core.injector.AbstractMethod; |
| | | import com.baomidou.mybatisplus.core.metadata.TableFieldInfo; |
| | | import com.baomidou.mybatisplus.core.metadata.TableInfo; |
| | | import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils; |
| | | import com.terra.collect.entity.all.StaticData; |
| | | import org.apache.ibatis.mapping.MappedStatement; |
| | | import org.apache.ibatis.mapping.SqlSource; |
| | | |
| | | /** |
| | | * æ¹éæ´æ°æ¹æ³ |
| | | * @author WWW |
| | | */ |
| | | @SuppressWarnings("ALL") |
| | | public class UpdateBatchMethod extends AbstractMethod { |
| | | /** |
| | | * update user set name = "a", age = 17 where id = 1; |
| | | * update user set name = "b", age = 18 where id = 2; |
| | | * <script> |
| | | * <foreach collection="list" item="item" separator=";"> |
| | | * update user |
| | | * <set> |
| | | * <if test="item.name != null and item.name != ''"> |
| | | * name = #{item.name,jdbcType=VARCHAR}, |
| | | * </if> |
| | | * <if test="item.age != null"> |
| | | * age = #{item.age,jdbcType=INTEGER}, |
| | | * </if> |
| | | * </set> |
| | | * where id = #{item.id,jdbcType=INTEGER} |
| | | * </foreach> |
| | | * </script> |
| | | */ |
| | | @Override |
| | | public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) { |
| | | String sql = "<script>\n<foreach collection=\"list\" item=\"item\" separator=\";\">\nupdate %s %s where %s=#{%s} %s\n</foreach>\n</script>"; |
| | | String additional = tableInfo.isWithVersion() ? tableInfo.getVersionFieldInfo().getVersionOli("item", "item.") : "" + tableInfo.getLogicDeleteSql(true, true); |
| | | //String setSql = sqlSet(tableInfo.isWithLogicDelete(), false, tableInfo, false, "item", "item."); |
| | | String setSql = getSqlSet(tableInfo.isWithLogicDelete(), false, tableInfo, false, "item", "item."); |
| | | String sqlResult = String.format(sql, tableInfo.getTableName(), setSql, tableInfo.getKeyColumn(), "item." + tableInfo.getKeyProperty(), additional); |
| | | |
| | | // update %s %s where %s=#{%s} %s |
| | | // update tab set a=#{a} where gid=1 |
| | | |
| | | SqlSource sqlSource = languageDriver.createSqlSource(configuration, sqlResult, modelClass); |
| | | |
| | | // 第ä¸ä¸ªåæ°å¿
é¡»åRootMapperçèªå®ä¹æ¹æ³åä¸è´ |
| | | return this.addUpdateMappedStatement(mapperClass, modelClass, "updateBatch", sqlSource); |
| | | } |
| | | |
| | | private String getSqlSet(boolean logic, boolean ew, TableInfo table, boolean judgeAliasNull, final String alias, final String prefix) { |
| | | // String sqlScript = table.getAllSqlSet(logic, prefix); |
| | | String sqlScript = getSqlSet(table); |
| | | if (judgeAliasNull) { |
| | | sqlScript = SqlScriptUtils.convertIf(sqlScript, String.format("%s != null", alias), true); |
| | | } |
| | | if (ew) { |
| | | sqlScript = sqlScript + "\n"; |
| | | sqlScript = sqlScript + this.convertIfEwParam("ew.sqlSet", false); |
| | | } |
| | | |
| | | sqlScript = SqlScriptUtils.convertSet(sqlScript); |
| | | |
| | | return sqlScript; |
| | | } |
| | | |
| | | private String getSqlSet(TableInfo tableInfo) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (TableFieldInfo f : tableInfo.getFieldList()) { |
| | | if (StaticData.UPDATE_EXCLUDE_FIELDS.contains(f.getProperty())) { |
| | | continue; |
| | | } |
| | | |
| | | if ("geom".equals(f.getProperty())) { |
| | | sb.append("<if test=\"item['geom'] != null\">geom=${item.geom},</if>\n"); |
| | | continue; |
| | | } |
| | | |
| | | sb.append(String.format("<if test=\"item['%s'] != null\">%s=#{item.%s},</if>\n", f.getProperty(), f.getColumn(), f.getProperty())); |
| | | } |
| | | sb.deleteCharAt(sb.length() - 1); |
| | | |
| | | return sb.toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.terra.collect.mapper.all; |
| | | |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface PermsMapper { |
| | | public List<Integer> selectRoles(String uid); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.terra.collect.mapper.all.PermsMapper"> |
| | | <select id="selectRoles" resultType="java.lang.Integer"> |
| | | select is_admin from lf.sys_role a inner join lf.sys_role_user b on a.id = b.roleid |
| | | inner join lf.sys_user c on b.userid = c.id where c.uid = #{uid} |
| | | </select> |
| | | </mapper> |
| | |
| | | <!--âç±»åå«åé
ç½®--> |
| | | <package name="com.terra.collect.entity"/> |
| | | </typeAliases> |
| | | <mappers> |
| | | <!--Mapperæä»¶ä½ç½®é
ç½®--> |
| | | <mapper resource="mapper/**/*.xml" /> |
| | | </mappers> |
| | | </configuration> |
| | |
| | | <!--âç±»åå«åé
ç½®--> |
| | | <package name="com.terra.collect.entity"/> |
| | | </typeAliases> |
| | | <mappers> |
| | | <!--Mapperæä»¶ä½ç½®é
ç½®--> |
| | | <mapper resource="mapper/**/*.xml" /> |
| | | </mappers> |
| | | </configuration> |
| | |
| | | <!--âç±»åå«åé
ç½®--> |
| | | <package name="com.terra.collect.entity"/> |
| | | </typeAliases> |
| | | <mappers> |
| | | <!--Mapperæä»¶ä½ç½®é
ç½®--> |
| | | <mapper resource="mapper/**/*.xml" /> |
| | | </mappers> |
| | | </configuration> |
| | |
| | | <!--âç±»åå«åé
ç½®--> |
| | | <package name="com.terra.collect.entity"/> |
| | | </typeAliases> |
| | | <mappers> |
| | | <!--Mapperæä»¶ä½ç½®é
ç½®--> |
| | | <mapper resource="mapper/**/*.xml" /> |
| | | </mappers> |
| | | </configuration> |