feat: add highgo support, and fix bugs
This commit is contained in:
@@ -42,8 +42,11 @@ public interface TableMapper {
|
|||||||
List<Map<String, Object>> getListNoPage(@Param("typeName") String tableName, @Param("info") Map<String, Object> map);
|
List<Map<String, Object>> getListNoPage(@Param("typeName") String tableName, @Param("info") Map<String, Object> map);
|
||||||
|
|
||||||
Object getSequence(@Param("tableName") String tableName);
|
Object getSequence(@Param("tableName") String tableName);
|
||||||
|
Object getHighGoSequence(@Param("tableName") String tableName);
|
||||||
|
boolean judgeHighGoSequenceExist(@Param("tableName") String tableName);
|
||||||
|
boolean judgeDamengSequenceExist(@Param("tableName") String tableName);
|
||||||
int createSequence(@Param("tableName") String tableName, @Param("lastId")Object lastId);
|
int createSequence(@Param("tableName") String tableName, @Param("lastId")Object lastId);
|
||||||
|
int createHighGoSequence(@Param("tableName") String tableName, @Param("lastId")Object lastId);
|
||||||
|
|
||||||
Long count(@Param("tableName")String tableName,@Param("sql")String sql);
|
Long count(@Param("tableName")String tableName,@Param("sql")String sql);
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import java.util.Map;
|
|||||||
public interface BaseMapper {
|
public interface BaseMapper {
|
||||||
|
|
||||||
<E> int save(DataMap<E> dataMap);
|
<E> int save(DataMap<E> dataMap);
|
||||||
|
String getDataConfig();
|
||||||
int save(String tableName, String pkName, Map<String, Object> data);
|
int save(String tableName, String pkName, Map<String, Object> data);
|
||||||
|
|
||||||
<E> int save(E e);
|
<E> int save(E e);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> int save(DataMap<E> dataMap) {
|
public String getDataConfig() {
|
||||||
String key;
|
String key;
|
||||||
DatasourceConfig datasourceConfig = new DatasourceConfig();
|
DatasourceConfig datasourceConfig = new DatasourceConfig();
|
||||||
try {
|
try {
|
||||||
@@ -58,17 +58,26 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
if (dataType.contains("sqlite")) {
|
if (dataType.contains("sqlite")) {
|
||||||
datasourceConfig.setCommonType(DataUnit.SQLITE);
|
datasourceConfig.setCommonType(DataUnit.SQLITE);
|
||||||
}
|
}
|
||||||
if(dataType.contains("highgo")) {
|
if (dataType.contains("highgo")) {
|
||||||
datasourceConfig.setCommonType(DataUnit.HANGO);
|
datasourceConfig.setCommonType(DataUnit.HANGO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return datasourceConfig.getCommonType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <E> int save(DataMap<E> dataMap) {
|
||||||
|
String dataType = getDataConfig();
|
||||||
JudgesNull(dataMap.getData(), "data can not be null!");
|
JudgesNull(dataMap.getData(), "data can not be null!");
|
||||||
JudgesNull(dataMap.getTableName(), "tableName can not be null!");
|
JudgesNull(dataMap.getTableName(), "tableName can not be null!");
|
||||||
|
if(DataUnit.HANGO.equals(dataType)){
|
||||||
|
dataMap.setData(formatMap(dataMap.getData()));
|
||||||
|
}
|
||||||
if (StringUtils.isEmpty(dataMap.getPkName())) {
|
if (StringUtils.isEmpty(dataMap.getPkName())) {
|
||||||
dataMap.setPkName("ID");
|
dataMap.setPkName("ID");
|
||||||
}
|
}
|
||||||
int i;
|
int i;
|
||||||
if (DataUnit.ORACLE.equals(datasourceConfig.getCommonType()) || DataUnit.DAMENG.equals(datasourceConfig.getCommonType()) || DataUnit.HANGO.equals(datasourceConfig.getCommonType())) {
|
if (DataUnit.ORACLE.equals(dataType) || DataUnit.DAMENG.equals(dataType) || DataUnit.HANGO.equals(dataType)) {
|
||||||
if (org.springframework.util.StringUtils.isEmpty(dataMap.get(dataMap.getPkName()))) {
|
if (org.springframework.util.StringUtils.isEmpty(dataMap.get(dataMap.getPkName()))) {
|
||||||
Object id = getSequence(dataMap.getTableName(), dataMap.getPkName());
|
Object id = getSequence(dataMap.getTableName(), dataMap.getPkName());
|
||||||
dataMap.toBuilder().add(dataMap.getPkName(), id);
|
dataMap.toBuilder().add(dataMap.getPkName(), id);
|
||||||
@@ -85,38 +94,37 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatTable(String tableName) {
|
public Map<String, Object> formatMap(Map<String, Object> data){
|
||||||
return "`"+tableName+"`";
|
// 遍历 Map 并转换值
|
||||||
|
for (Map.Entry<String, Object> entry : data.entrySet()) {
|
||||||
|
Object value = entry.getValue();
|
||||||
|
if (value instanceof String) {
|
||||||
|
String strValue = (String) value;
|
||||||
|
if (strValue.matches("-?\\d+")) { // 匹配整数
|
||||||
|
data.put(entry.getKey(), Long.parseLong(strValue));
|
||||||
|
} else if (strValue.matches("-?\\d*\\.\\d+")) { // 匹配浮点数
|
||||||
|
data.put(entry.getKey(), (long) Double.parseDouble(strValue));
|
||||||
|
}
|
||||||
|
} else if (value instanceof Number) {
|
||||||
|
data.put(entry.getKey(), ((Number) value).longValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int save(String tableName, String pkName, Map<String, Object> data) {
|
public int save(String tableName, String pkName, Map<String, Object> data) {
|
||||||
JudgesNull(tableName, "data can not be null!");
|
JudgesNull(tableName, "data can not be null!");
|
||||||
JudgesNull(data, "tableName can not be null!");
|
JudgesNull(data, "tableName can not be null!");
|
||||||
tableName = formatTable(tableName);
|
String dataType = getDataConfig();
|
||||||
String key;
|
if(DataUnit.HANGO.equals(dataType)){
|
||||||
DatasourceConfig datasourceConfig = new DatasourceConfig();
|
data = formatMap(data);
|
||||||
try {
|
|
||||||
key = DBContextHolder.getDataSource();
|
|
||||||
datasourceConfig = DataSourceUtil.get(key);
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (dataType.contains("oracle")) {
|
|
||||||
datasourceConfig.setCommonType(DataUnit.ORACLE);
|
|
||||||
}
|
|
||||||
if (dataType.contains("mysql")) {
|
|
||||||
datasourceConfig.setCommonType(DataUnit.MYSQL);
|
|
||||||
}
|
|
||||||
if (dataType.contains("DmDriver")) {
|
|
||||||
datasourceConfig.setCommonType(DataUnit.DAMENG);
|
|
||||||
}
|
|
||||||
if (dataType.contains("sqlite")) {
|
|
||||||
datasourceConfig.setCommonType(DataUnit.SQLITE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(pkName)) {
|
if (StringUtils.isEmpty(pkName)) {
|
||||||
pkName = "ID";
|
pkName = "ID";
|
||||||
}
|
}
|
||||||
int i;
|
int i;
|
||||||
if (datasourceConfig.getCommonType().equals(DataUnit.ORACLE) || datasourceConfig.getCommonType().equals(DataUnit.DAMENG)) {
|
if (DataUnit.ORACLE.equals(dataType) || DataUnit.DAMENG.equals(dataType) || DataUnit.HANGO.equals(dataType)) {
|
||||||
if (org.springframework.util.StringUtils.isEmpty(data.get(pkName))) {
|
if (org.springframework.util.StringUtils.isEmpty(data.get(pkName))) {
|
||||||
data.put(pkName, getSequence(tableName, pkName));
|
data.put(pkName, getSequence(tableName, pkName));
|
||||||
}
|
}
|
||||||
@@ -139,9 +147,8 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
|
|
||||||
private int updateByWhere(Condition condition, String tableName, Map<String, Object> data) {
|
private int updateByWhere(Condition condition, String tableName, Map<String, Object> data) {
|
||||||
Map<String, Object> params = condition.getParamMap();
|
Map<String, Object> params = condition.getParamMap();
|
||||||
tableName = formatTable(tableName);
|
|
||||||
params.put("tableName", tableName);
|
params.put("tableName", tableName);
|
||||||
params.put("info", data);
|
params.put("info", formatMap(data));
|
||||||
params.put("sql", condition.getSql());
|
params.put("sql", condition.getSql());
|
||||||
int i = sqlSessionTemplate.update(TABLE_MAPPER_PACKAGE + "updateByWhere", params);
|
int i = sqlSessionTemplate.update(TABLE_MAPPER_PACKAGE + "updateByWhere", params);
|
||||||
return i;
|
return i;
|
||||||
@@ -252,7 +259,6 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
|
|
||||||
private int deleteByWhere(Condition condition, String tableName) {
|
private int deleteByWhere(Condition condition, String tableName) {
|
||||||
Map<String, Object> params = condition.getParamMap();
|
Map<String, Object> params = condition.getParamMap();
|
||||||
tableName = formatTable(tableName);
|
|
||||||
params.put("tableName", tableName);
|
params.put("tableName", tableName);
|
||||||
params.put("sql", condition.getSql());
|
params.put("sql", condition.getSql());
|
||||||
return sqlSessionTemplate.delete(TABLE_MAPPER_PACKAGE + "deleteByWhere", params);
|
return sqlSessionTemplate.delete(TABLE_MAPPER_PACKAGE + "deleteByWhere", params);
|
||||||
@@ -339,7 +345,6 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> selectAll(String tableName) {
|
public List<Map<String, Object>> selectAll(String tableName) {
|
||||||
JudgesNull(tableName, "tableName can not be null!");
|
JudgesNull(tableName, "tableName can not be null!");
|
||||||
tableName = formatTable(tableName);
|
|
||||||
return tableMapper.useSql(SelectCondition.builder().tableName(tableName).build().getSql());
|
return tableMapper.useSql(SelectCondition.builder().tableName(tableName).build().getSql());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,8 +392,8 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
public <E> PageInfo<Map<String, Object>> selectByEqual(DataMap<E> dataMap, Map<String, Object> map, WebPageInfo webPageInfo) {
|
public <E> PageInfo<Map<String, Object>> selectByEqual(DataMap<E> dataMap, Map<String, Object> map, WebPageInfo webPageInfo) {
|
||||||
JudgesNull(dataMap.getTableName(), "tableName can not be null!");
|
JudgesNull(dataMap.getTableName(), "tableName can not be null!");
|
||||||
Condition condition = equal(dataMap, map);
|
Condition condition = equal(dataMap, map);
|
||||||
if(webPageInfo.isEnableCache()){
|
if (webPageInfo.isEnableCache()) {
|
||||||
return MyPageHelper.start(webPageInfo,condition.getSql(),() -> selectList(condition));
|
return MyPageHelper.start(webPageInfo, condition.getSql(), () -> selectList(condition));
|
||||||
}
|
}
|
||||||
MyPageHelper.start(webPageInfo);
|
MyPageHelper.start(webPageInfo);
|
||||||
return new PageInfo<>(selectList(condition));
|
return new PageInfo<>(selectList(condition));
|
||||||
@@ -398,8 +403,8 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
public PageInfo<Map<String, Object>> selectByEqual(String tableName, Map<String, Object> map, WebPageInfo webPageInfo) {
|
public PageInfo<Map<String, Object>> selectByEqual(String tableName, Map<String, Object> map, WebPageInfo webPageInfo) {
|
||||||
JudgesNull(tableName, "tableName can not be null!");
|
JudgesNull(tableName, "tableName can not be null!");
|
||||||
Condition condition = equal(DataMap.builder().tableName(tableName).build(), map);
|
Condition condition = equal(DataMap.builder().tableName(tableName).build(), map);
|
||||||
if(webPageInfo.isEnableCache()){
|
if (webPageInfo.isEnableCache()) {
|
||||||
return MyPageHelper.start(webPageInfo,condition.getSql(),() -> selectList(condition));
|
return MyPageHelper.start(webPageInfo, condition.getSql(), () -> selectList(condition));
|
||||||
}
|
}
|
||||||
MyPageHelper.start(webPageInfo);
|
MyPageHelper.start(webPageInfo);
|
||||||
return new PageInfo<>(selectList(condition));
|
return new PageInfo<>(selectList(condition));
|
||||||
@@ -482,8 +487,8 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
@Override
|
@Override
|
||||||
public PageInfo<Map<String, Object>> selectByCondition(Condition condition, WebPageInfo webPageInfo) {
|
public PageInfo<Map<String, Object>> selectByCondition(Condition condition, WebPageInfo webPageInfo) {
|
||||||
MyPageHelper.start(webPageInfo);
|
MyPageHelper.start(webPageInfo);
|
||||||
if(webPageInfo.isEnableCache()){
|
if (webPageInfo.isEnableCache()) {
|
||||||
return MyPageHelper.start(webPageInfo,condition.getSql(),() -> selectList(condition));
|
return MyPageHelper.start(webPageInfo, condition.getSql(), () -> selectList(condition));
|
||||||
}
|
}
|
||||||
return new PageInfo<>(selectList(condition));
|
return new PageInfo<>(selectList(condition));
|
||||||
}
|
}
|
||||||
@@ -492,9 +497,9 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
public <E> PageInfo<Map<String, Object>> selectByCondition(DataMap<E> dataMap, Condition condition, WebPageInfo webPageInfo) {
|
public <E> PageInfo<Map<String, Object>> selectByCondition(DataMap<E> dataMap, Condition condition, WebPageInfo webPageInfo) {
|
||||||
JudgesNull(dataMap.getTableName(), "tableName can not be null!");
|
JudgesNull(dataMap.getTableName(), "tableName can not be null!");
|
||||||
condition = condition.toCreatCriteria(dataMap).build();
|
condition = condition.toCreatCriteria(dataMap).build();
|
||||||
if(webPageInfo.isEnableCache()){
|
if (webPageInfo.isEnableCache()) {
|
||||||
Condition finalCondition = condition;
|
Condition finalCondition = condition;
|
||||||
return MyPageHelper.start(webPageInfo,condition.getSql(),() -> selectList(finalCondition));
|
return MyPageHelper.start(webPageInfo, condition.getSql(), () -> selectList(finalCondition));
|
||||||
}
|
}
|
||||||
MyPageHelper.start(webPageInfo);
|
MyPageHelper.start(webPageInfo);
|
||||||
return new PageInfo<>(selectList(condition));
|
return new PageInfo<>(selectList(condition));
|
||||||
@@ -504,9 +509,9 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
public PageInfo<Map<String, Object>> selectByCondition(String tableName, Condition condition, WebPageInfo webPageInfo) {
|
public PageInfo<Map<String, Object>> selectByCondition(String tableName, Condition condition, WebPageInfo webPageInfo) {
|
||||||
JudgesNull(tableName, "tableName can not be null!");
|
JudgesNull(tableName, "tableName can not be null!");
|
||||||
condition = condition.toCreatCriteria(DataMap.builder().tableName(tableName).build()).build();
|
condition = condition.toCreatCriteria(DataMap.builder().tableName(tableName).build()).build();
|
||||||
if(webPageInfo.isEnableCache()){
|
if (webPageInfo.isEnableCache()) {
|
||||||
Condition finalCondition = condition;
|
Condition finalCondition = condition;
|
||||||
return MyPageHelper.start(webPageInfo,condition.getSql(),() -> selectList(finalCondition));
|
return MyPageHelper.start(webPageInfo, condition.getSql(), () -> selectList(finalCondition));
|
||||||
}
|
}
|
||||||
MyPageHelper.start(webPageInfo);
|
MyPageHelper.start(webPageInfo);
|
||||||
return new PageInfo<>(selectList(condition));
|
return new PageInfo<>(selectList(condition));
|
||||||
@@ -516,9 +521,9 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
public PageInfo<Map<String, Object>> selectByCondition(String tableName, List<String> fieldList, Condition condition, WebPageInfo webPageInfo) {
|
public PageInfo<Map<String, Object>> selectByCondition(String tableName, List<String> fieldList, Condition condition, WebPageInfo webPageInfo) {
|
||||||
JudgesNull(tableName, "tableName can not be null!");
|
JudgesNull(tableName, "tableName can not be null!");
|
||||||
condition = condition.toCreatCriteria(DataMap.builder().tableName(tableName).fieldList(fieldList).build()).build();
|
condition = condition.toCreatCriteria(DataMap.builder().tableName(tableName).fieldList(fieldList).build()).build();
|
||||||
if(webPageInfo.isEnableCache()){
|
if (webPageInfo.isEnableCache()) {
|
||||||
Condition finalCondition = condition;
|
Condition finalCondition = condition;
|
||||||
return MyPageHelper.start(webPageInfo,condition.getSql(),() -> selectList(finalCondition));
|
return MyPageHelper.start(webPageInfo, condition.getSql(), () -> selectList(finalCondition));
|
||||||
}
|
}
|
||||||
MyPageHelper.start(webPageInfo);
|
MyPageHelper.start(webPageInfo);
|
||||||
return new PageInfo<>(selectList(condition));
|
return new PageInfo<>(selectList(condition));
|
||||||
@@ -528,9 +533,9 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
public PageInfo<Map<String, Object>> selectByCondition(String tableName, String fieldList, Condition condition, WebPageInfo webPageInfo) {
|
public PageInfo<Map<String, Object>> selectByCondition(String tableName, String fieldList, Condition condition, WebPageInfo webPageInfo) {
|
||||||
JudgesNull(tableName, "tableName can not be null!");
|
JudgesNull(tableName, "tableName can not be null!");
|
||||||
condition = condition.toCreatCriteria(DataMap.builder().tableName(tableName).fields(fieldList).build()).build();
|
condition = condition.toCreatCriteria(DataMap.builder().tableName(tableName).fields(fieldList).build()).build();
|
||||||
if(webPageInfo.isEnableCache()){
|
if (webPageInfo.isEnableCache()) {
|
||||||
Condition finalCondition = condition;
|
Condition finalCondition = condition;
|
||||||
return MyPageHelper.start(webPageInfo,condition.getSql(),() -> selectList(finalCondition));
|
return MyPageHelper.start(webPageInfo, condition.getSql(), () -> selectList(finalCondition));
|
||||||
}
|
}
|
||||||
MyPageHelper.start(webPageInfo);
|
MyPageHelper.start(webPageInfo);
|
||||||
return new PageInfo<>(selectList(condition));
|
return new PageInfo<>(selectList(condition));
|
||||||
@@ -579,7 +584,6 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> selectJoinByCondition(String tableName, List<JoinCondition> joinCondition, Condition condition) {
|
public List<Map<String, Object>> selectJoinByCondition(String tableName, List<JoinCondition> joinCondition, Condition condition) {
|
||||||
JudgesNull(tableName, "tableName can not be null!");
|
JudgesNull(tableName, "tableName can not be null!");
|
||||||
@@ -637,8 +641,8 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageInfo<Map<String, Object>> selectSqlByPage(String sql, WebPageInfo webPageInfo) {
|
public PageInfo<Map<String, Object>> selectSqlByPage(String sql, WebPageInfo webPageInfo) {
|
||||||
if(webPageInfo.isEnableCache()){
|
if (webPageInfo.isEnableCache()) {
|
||||||
return MyPageHelper.start(webPageInfo,sql,() -> (tableMapper.useSql(sql)));
|
return MyPageHelper.start(webPageInfo, sql, () -> (tableMapper.useSql(sql)));
|
||||||
}
|
}
|
||||||
MyPageHelper.start(webPageInfo);
|
MyPageHelper.start(webPageInfo);
|
||||||
return new PageInfo<>(tableMapper.useSql(sql));
|
return new PageInfo<>(tableMapper.useSql(sql));
|
||||||
@@ -646,15 +650,15 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> selectSql(String sql, Map<String, Object> params) {
|
public List<Map<String, Object>> selectSql(String sql, Map<String, Object> params) {
|
||||||
params.put("sql",sql);
|
params.put("sql", sql);
|
||||||
return sqlSessionTemplate.selectList(TABLE_MAPPER_PACKAGE + "useSql", params);
|
return sqlSessionTemplate.selectList(TABLE_MAPPER_PACKAGE + "useSql", params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageInfo<Map<String, Object>> selectSqlByPage(String sql, Map<String, Object> params, WebPageInfo webPageInfo) {
|
public PageInfo<Map<String, Object>> selectSqlByPage(String sql, Map<String, Object> params, WebPageInfo webPageInfo) {
|
||||||
params.put("sql",sql);
|
params.put("sql", sql);
|
||||||
if(webPageInfo.isEnableCache()){
|
if (webPageInfo.isEnableCache()) {
|
||||||
return MyPageHelper.start(webPageInfo,sql,() -> sqlSessionTemplate.selectList(TABLE_MAPPER_PACKAGE + "useSql", params));
|
return MyPageHelper.start(webPageInfo, sql, () -> sqlSessionTemplate.selectList(TABLE_MAPPER_PACKAGE + "useSql", params));
|
||||||
}
|
}
|
||||||
MyPageHelper.start(webPageInfo);
|
MyPageHelper.start(webPageInfo);
|
||||||
return new PageInfo<>(sqlSessionTemplate.selectList(TABLE_MAPPER_PACKAGE + "useSql", params));
|
return new PageInfo<>(sqlSessionTemplate.selectList(TABLE_MAPPER_PACKAGE + "useSql", params));
|
||||||
@@ -667,16 +671,16 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> selectOneSql(String sql, Map<String, Object> params) {
|
public Map<String, Object> selectOneSql(String sql, Map<String, Object> params) {
|
||||||
params.put("sql",sql);
|
params.put("sql", sql);
|
||||||
return sqlSessionTemplate.selectOne(TABLE_MAPPER_PACKAGE + "userSqlByOne", params);
|
return sqlSessionTemplate.selectOne(TABLE_MAPPER_PACKAGE + "userSqlByOne", params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long count(String tableName, Condition condition) {
|
public Long count(String tableName, Condition condition) {
|
||||||
String sql = condition.getSql();
|
String sql = condition.getSql();
|
||||||
sql = "SELECT count(0) as COUNT FROM "+tableName+" " + sql;
|
sql = "SELECT count(0) as COUNT FROM " + tableName + " " + sql;
|
||||||
condition.setSql(sql);
|
condition.setSql(sql);
|
||||||
Map<String,Object> map = selectOne(condition);
|
Map<String, Object> map = selectOne(condition);
|
||||||
return Long.parseLong(String.valueOf(map.get("COUNT")));
|
return Long.parseLong(String.valueOf(map.get("COUNT")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -689,7 +693,7 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
public int saveBatch(String tableName, String pkName, List<Map<String, Object>> list) {
|
public int saveBatch(String tableName, String pkName, List<Map<String, Object>> list) {
|
||||||
JudgesNull(tableName, "tableName can not be null!");
|
JudgesNull(tableName, "tableName can not be null!");
|
||||||
JudgesNull(pkName, "pkName can not be null!");
|
JudgesNull(pkName, "pkName can not be null!");
|
||||||
if(list==null|| list.isEmpty()){
|
if (list == null || list.isEmpty()) {
|
||||||
throw new ServiceException("list can not empty");
|
throw new ServiceException("list can not empty");
|
||||||
}
|
}
|
||||||
// JudgesNull(data, "tableName can not be null!");
|
// JudgesNull(data, "tableName can not be null!");
|
||||||
@@ -717,9 +721,9 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (datasourceConfig.getCommonType().equals(DataUnit.ORACLE) || datasourceConfig.getCommonType().equals(DataUnit.DAMENG)) {
|
if (datasourceConfig.getCommonType().equals(DataUnit.ORACLE) || datasourceConfig.getCommonType().equals(DataUnit.DAMENG)) {
|
||||||
for(Map<String,Object> map:list){
|
for (Map<String, Object> map : list) {
|
||||||
Object id = getSequence(tableName, pkName);
|
Object id = getSequence(tableName, pkName);
|
||||||
map.put(pkName,id);
|
map.put(pkName, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int i = tableMapper.insertBatch(list, tableName);
|
int i = tableMapper.insertBatch(list, tableName);
|
||||||
@@ -731,7 +735,7 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
public int updateBatchByPk(String tableName, String pkName, List<Map<String, Object>> list) {
|
public int updateBatchByPk(String tableName, String pkName, List<Map<String, Object>> list) {
|
||||||
JudgesNull(tableName, "tableName can not be null!");
|
JudgesNull(tableName, "tableName can not be null!");
|
||||||
JudgesNull(pkName, "pkName can not be null!");
|
JudgesNull(pkName, "pkName can not be null!");
|
||||||
if(list==null|| list.isEmpty()){
|
if (list == null || list.isEmpty()) {
|
||||||
throw new ServiceException("list can not empty");
|
throw new ServiceException("list can not empty");
|
||||||
}
|
}
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
@@ -765,7 +769,7 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
paramMap.put("sql", sql.toString());
|
paramMap.put("sql", sql.toString());
|
||||||
return this.sqlSessionTemplate.update(TABLE_MAPPER_PACKAGE+"updateBatchByPk", paramMap);
|
return this.sqlSessionTemplate.update(TABLE_MAPPER_PACKAGE + "updateBatchByPk", paramMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void JudgesNull(Object object, String str) {
|
public void JudgesNull(Object object, String str) {
|
||||||
@@ -775,20 +779,36 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Object getSequence(String tableName, String pkName) {
|
public Object getSequence(String tableName, String pkName) {
|
||||||
|
String dataType = getDataConfig();
|
||||||
Object id;
|
Object id;
|
||||||
try {
|
if (DataUnit.HANGO.equals(dataType)) {
|
||||||
id = tableMapper.getSequence(tableName);
|
if (!tableMapper.judgeHighGoSequenceExist(tableName.toLowerCase())) {
|
||||||
} catch (Exception e) {
|
MyPageHelper.noCount(WebPageInfo.builder().pageNum(1).pageSize(1).order(WebPageInfo.DESC).sortField(pkName).build());
|
||||||
MyPageHelper.noCount(WebPageInfo.builder().pageNum(1).pageSize(1).order(WebPageInfo.DESC).sortField(pkName).build());
|
DataMap<Object> dataMap = DataMap.builder().tableName(tableName).pkName(pkName).fields(pkName).build();
|
||||||
DataMap<Object> dataMap = DataMap.builder().tableName(tableName).pkName(pkName).fields(pkName).build();
|
Condition condition = Condition.creatCriteria(dataMap).build();
|
||||||
Condition condition = Condition.creatCriteria(dataMap).build();
|
Map<String, Object> map = selectOneByCondition(condition);
|
||||||
Map<String, Object> map = selectOneByCondition(condition);
|
if (map == null) {
|
||||||
if (map == null) {
|
tableMapper.createHighGoSequence(tableName, 1);
|
||||||
tableMapper.createSequence(tableName, 1);
|
} else {
|
||||||
} else {
|
tableMapper.createHighGoSequence(tableName, map.get(pkName));
|
||||||
tableMapper.createSequence(tableName, map.get(pkName));
|
}
|
||||||
|
}
|
||||||
|
id = tableMapper.getHighGoSequence(tableName);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
id = tableMapper.getSequence(tableName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
MyPageHelper.noCount(WebPageInfo.builder().pageNum(1).pageSize(1).order(WebPageInfo.DESC).sortField(pkName).build());
|
||||||
|
DataMap<Object> dataMap = DataMap.builder().tableName(tableName).pkName(pkName).fields(pkName).build();
|
||||||
|
Condition condition = Condition.creatCriteria(dataMap).build();
|
||||||
|
Map<String, Object> map = selectOneByCondition(condition);
|
||||||
|
if (map == null) {
|
||||||
|
tableMapper.createSequence(tableName, 1);
|
||||||
|
} else {
|
||||||
|
tableMapper.createSequence(tableName, map.get(pkName));
|
||||||
|
}
|
||||||
|
id = tableMapper.getSequence(tableName);
|
||||||
}
|
}
|
||||||
id = tableMapper.getSequence(tableName);
|
|
||||||
}
|
}
|
||||||
return Long.parseLong(id.toString()) + 1L;
|
return Long.parseLong(id.toString()) + 1L;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public class Condition implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ConditionBuilder creatCriteria(SelectCondition selectCondition) {
|
public static ConditionBuilder creatCriteria(SelectCondition selectCondition) {
|
||||||
return new ConditionBuilder(selectCondition,new HashMap<>());
|
return new ConditionBuilder(selectCondition, new HashMap<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConditionBuilder creatCriteria(SelectCondition selectCondition, boolean flag) {
|
public static ConditionBuilder creatCriteria(SelectCondition selectCondition, boolean flag) {
|
||||||
@@ -128,7 +128,7 @@ public class Condition implements Serializable {
|
|||||||
|
|
||||||
public static ConditionBuilder creatCriteria(DataMap dataMap) {
|
public static ConditionBuilder creatCriteria(DataMap dataMap) {
|
||||||
JudesNull(dataMap.getTableName(), "tableName can not be null!");
|
JudesNull(dataMap.getTableName(), "tableName can not be null!");
|
||||||
return new ConditionBuilder(dataMap.getSelectCondition(),new HashMap<>());
|
return new ConditionBuilder(dataMap.getSelectCondition(), new HashMap<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConditionBuilder creatCriteria(DataMap dataMap, boolean flag) {
|
public static ConditionBuilder creatCriteria(DataMap dataMap, boolean flag) {
|
||||||
@@ -147,15 +147,15 @@ public class Condition implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ConditionBuilder toCreatCriteria() {
|
public ConditionBuilder toCreatCriteria() {
|
||||||
return new ConditionBuilder(this.sql,this.paramMap);
|
return new ConditionBuilder(this.sql, this.paramMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConditionBuilder toCreatCriteria(SelectCondition selectCondition) {
|
public ConditionBuilder toCreatCriteria(SelectCondition selectCondition) {
|
||||||
return new ConditionBuilder(selectCondition, this.sql,this.paramMap);
|
return new ConditionBuilder(selectCondition, this.sql, this.paramMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConditionBuilder toCreatCriteria(DataMap dataMap) {
|
public ConditionBuilder toCreatCriteria(DataMap dataMap) {
|
||||||
return new ConditionBuilder(dataMap.getSelectCondition(), this.sql,this.paramMap);
|
return new ConditionBuilder(dataMap.getSelectCondition(), this.sql, this.paramMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ConditionBuilder {
|
public static class ConditionBuilder {
|
||||||
@@ -199,7 +199,7 @@ public class Condition implements Serializable {
|
|||||||
this.flag = flag;
|
this.flag = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConditionBuilder(SelectCondition selectCondition,Map<String,Object> paramMap) {
|
public ConditionBuilder(SelectCondition selectCondition, Map<String, Object> paramMap) {
|
||||||
this.selectCondition = selectCondition;
|
this.selectCondition = selectCondition;
|
||||||
this.selecSql = selectCondition.getSql();
|
this.selecSql = selectCondition.getSql();
|
||||||
this.paramMap = paramMap;
|
this.paramMap = paramMap;
|
||||||
@@ -211,7 +211,7 @@ public class Condition implements Serializable {
|
|||||||
this.selecSql = selectCondition.getSql();
|
this.selecSql = selectCondition.getSql();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConditionBuilder(SelectCondition selectCondition, String sql,Map<String,Object> paramMap) {
|
public ConditionBuilder(SelectCondition selectCondition, String sql, Map<String, Object> paramMap) {
|
||||||
spliteSql(sql);
|
spliteSql(sql);
|
||||||
this.selectCondition = selectCondition;
|
this.selectCondition = selectCondition;
|
||||||
this.selecSql = selectCondition.getSql();
|
this.selecSql = selectCondition.getSql();
|
||||||
@@ -240,7 +240,19 @@ public class Condition implements Serializable {
|
|||||||
this.selecSql = selectCondition.getSql();
|
this.selecSql = selectCondition.getSql();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConditionBuilder(String sql,Map<String,Object> paramMap) {
|
private Object formatValue(Object value) {
|
||||||
|
if(value instanceof String) {
|
||||||
|
String str = (String)value;
|
||||||
|
if (str.matches("-?\\d+")) { // 匹配整数
|
||||||
|
return Long.parseLong(str);
|
||||||
|
} else if (str.matches("-?\\d*\\.\\d+")) { // 匹配浮点数
|
||||||
|
return Double.parseDouble(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConditionBuilder(String sql, Map<String, Object> paramMap) {
|
||||||
this.sql = sql;
|
this.sql = sql;
|
||||||
this.paramMap = paramMap;
|
this.paramMap = paramMap;
|
||||||
spliteSql(sql);
|
spliteSql(sql);
|
||||||
@@ -273,8 +285,8 @@ public class Condition implements Serializable {
|
|||||||
value = value.toString().replaceAll("\"", "");
|
value = value.toString().replaceAll("\"", "");
|
||||||
}
|
}
|
||||||
String sqlKey = "item_" + IdUtil.fastUUID();
|
String sqlKey = "item_" + IdUtil.fastUUID();
|
||||||
this.conditionSql += " `" + key +"` "+ EQUAL + "#{" + sqlKey + "}";
|
this.conditionSql += " " + key + EQUAL + "#{" + sqlKey + "}";
|
||||||
this.paramMap.put(sqlKey, value);
|
this.paramMap.put(sqlKey, formatValue(value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,8 +301,12 @@ public class Condition implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ConditionBuilder like(String key, Object value) {
|
public ConditionBuilder like(String key, Object value) {
|
||||||
sqlCheckLike(value);
|
if (value.toString().contains("\"")) {
|
||||||
this.conditionSql += " `" + key +"` "+ " " + LIKE + " '" + value + "'";
|
value = value.toString().replaceAll("\"", "");
|
||||||
|
}
|
||||||
|
String sqlKey = "item_" + IdUtil.fastUUID();
|
||||||
|
this.conditionSql += " " + key + " " + LIKE + " CONCAT('%',#{" + sqlKey + "},'%')";
|
||||||
|
this.paramMap.put(sqlKey, formatValue(value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +326,7 @@ public class Condition implements Serializable {
|
|||||||
int i = 1;
|
int i = 1;
|
||||||
for (Object object : value) {
|
for (Object object : value) {
|
||||||
String sqlKey = "item_" + IdUtil.fastUUID();
|
String sqlKey = "item_" + IdUtil.fastUUID();
|
||||||
this.paramMap.put(sqlKey, object);
|
this.paramMap.put(sqlKey, formatValue(object));
|
||||||
inStr.append("#{").append(sqlKey).append("}");
|
inStr.append("#{").append(sqlKey).append("}");
|
||||||
if (i != value.size()) {
|
if (i != value.size()) {
|
||||||
inStr.append(",");
|
inStr.append(",");
|
||||||
@@ -318,7 +334,7 @@ public class Condition implements Serializable {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
inStr.append(R_CURVES);
|
inStr.append(R_CURVES);
|
||||||
this.conditionSql += " `" + key +"` "+ " " + IN + " " + inStr.toString();
|
this.conditionSql += " " + key + " " + IN + " " + inStr.toString();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,9 +351,9 @@ public class Condition implements Serializable {
|
|||||||
public ConditionBuilder between(String key, Object start, Object end) {
|
public ConditionBuilder between(String key, Object start, Object end) {
|
||||||
String sqlKey = "item_" + IdUtil.fastUUID();
|
String sqlKey = "item_" + IdUtil.fastUUID();
|
||||||
String sqlKey2 = "item_" + IdUtil.fastUUID();
|
String sqlKey2 = "item_" + IdUtil.fastUUID();
|
||||||
this.paramMap.put(sqlKey, start);
|
this.paramMap.put(sqlKey, formatValue(start));
|
||||||
this.paramMap.put(sqlKey2, end);
|
this.paramMap.put(sqlKey2, formatValue(end));
|
||||||
this.conditionSql += " `" + key +"` "+ " " + BETWEEN + " #{" + sqlKey + "} " + AND + " #{" + sqlKey2 + "} ";
|
this.conditionSql += " " + key + " " + BETWEEN + " #{" + sqlKey + "} " + AND + " #{" + sqlKey2 + "} ";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,8 +369,8 @@ public class Condition implements Serializable {
|
|||||||
|
|
||||||
public ConditionBuilder lt(String key, Object value) {
|
public ConditionBuilder lt(String key, Object value) {
|
||||||
String sqlKey = "item_" + IdUtil.fastUUID();
|
String sqlKey = "item_" + IdUtil.fastUUID();
|
||||||
this.paramMap.put(sqlKey, value);
|
this.paramMap.put(sqlKey, formatValue(value));
|
||||||
this.conditionSql += " `" + key +"` "+ " " + LT + " #{" + sqlKey + "} ";
|
this.conditionSql += " " + key + " " + LT + " #{" + sqlKey + "} ";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,8 +391,8 @@ public class Condition implements Serializable {
|
|||||||
|
|
||||||
public ConditionBuilder notEqual(String key, Object value) {
|
public ConditionBuilder notEqual(String key, Object value) {
|
||||||
String sqlKey = "item_" + IdUtil.fastUUID();
|
String sqlKey = "item_" + IdUtil.fastUUID();
|
||||||
this.paramMap.put(sqlKey, value);
|
this.paramMap.put(sqlKey, formatValue(value));
|
||||||
this.conditionSql += " `" + key +"` "+ " " + NOT_EQUAL + " #{" + sqlKey + "} ";
|
this.conditionSql += " " + key + " " + NOT_EQUAL + " #{" + sqlKey + "} ";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -392,8 +408,8 @@ public class Condition implements Serializable {
|
|||||||
|
|
||||||
public ConditionBuilder gt(String key, Object value) {
|
public ConditionBuilder gt(String key, Object value) {
|
||||||
String sqlKey = "item_" + IdUtil.fastUUID();
|
String sqlKey = "item_" + IdUtil.fastUUID();
|
||||||
this.paramMap.put(sqlKey, value);
|
this.paramMap.put(sqlKey, formatValue(value));
|
||||||
this.conditionSql += " `" + key +"` "+ " " + GT + " #{" + sqlKey + "} ";
|
this.conditionSql += " " + key + " " + GT + " #{" + sqlKey + "} ";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,8 +425,8 @@ public class Condition implements Serializable {
|
|||||||
|
|
||||||
public ConditionBuilder lte(String key, Object value) {
|
public ConditionBuilder lte(String key, Object value) {
|
||||||
String sqlKey = "item_" + IdUtil.fastUUID();
|
String sqlKey = "item_" + IdUtil.fastUUID();
|
||||||
this.paramMap.put(sqlKey, value);
|
this.paramMap.put(sqlKey, formatValue(value));
|
||||||
this.conditionSql += " `" + key +"` "+ " " + LTE + " #{" + value.toString() + "} ";
|
this.conditionSql += " " + key + " " + LTE + " #{" + value.toString() + "} ";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,8 +442,8 @@ public class Condition implements Serializable {
|
|||||||
|
|
||||||
public ConditionBuilder gte(String key, Object value) {
|
public ConditionBuilder gte(String key, Object value) {
|
||||||
String sqlKey = "item_" + IdUtil.fastUUID();
|
String sqlKey = "item_" + IdUtil.fastUUID();
|
||||||
this.paramMap.put(sqlKey, value);
|
this.paramMap.put(sqlKey, formatValue(value));
|
||||||
this.conditionSql += " `" + key +"` "+ " " + GTE + " #{" + value.toString() + "} ";
|
this.conditionSql += " " + key + " " + GTE + " #{" + value.toString() + "} ";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,7 +508,7 @@ public class Condition implements Serializable {
|
|||||||
if (StringUtils.isEmpty(this.conditionSql)) {
|
if (StringUtils.isEmpty(this.conditionSql)) {
|
||||||
this.sql = this.selecSql;
|
this.sql = this.selecSql;
|
||||||
}
|
}
|
||||||
return new Condition(this.sql, this.selectCondition,this.paramMap);
|
return new Condition(this.sql, this.selectCondition, this.paramMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.taixingyiji.base.module.data.module;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import tk.mybatis.mapper.autoconfigure.ConfigurationCustomizer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className MyBatisConfig
|
||||||
|
* @author lhc
|
||||||
|
* @date 2025年03月28日 19:43
|
||||||
|
* @description 描述
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class MyBatisConfig {
|
||||||
|
@Value("${mybatis.enable-highgo}")
|
||||||
|
private boolean customObjectWrapperEnabled;
|
||||||
|
@Bean
|
||||||
|
public ConfigurationCustomizer configurationCustomizer() {
|
||||||
|
return configuration -> {
|
||||||
|
if (customObjectWrapperEnabled) {
|
||||||
|
configuration.setObjectWrapperFactory(new UpperCaseMapWrapperFactory());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -113,7 +113,7 @@ public class SelectCondition implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SelectBuilder tableName(String tableName) {
|
public SelectBuilder tableName(String tableName) {
|
||||||
this.tableName = "`"+tableName+"`";
|
this.tableName = tableName;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.taixingyiji.base.module.data.module;
|
||||||
|
|
||||||
|
import org.apache.ibatis.reflection.MetaObject;
|
||||||
|
import org.apache.ibatis.reflection.wrapper.MapWrapper;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lhc
|
||||||
|
* @version 1.0
|
||||||
|
* @className UpperCaseMapWrapper
|
||||||
|
* @date 2025年03月28日 19:41
|
||||||
|
* @description 描述
|
||||||
|
*/
|
||||||
|
public class UpperCaseMapWrapper extends MapWrapper {
|
||||||
|
|
||||||
|
public UpperCaseMapWrapper(MetaObject metaObject, Map<String, Object> map) {
|
||||||
|
super(metaObject, map);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String findProperty(String name, boolean useCamelCaseMapping) {
|
||||||
|
return name==null?"":name.toUpperCase() ;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.taixingyiji.base.module.data.module;
|
||||||
|
import org.apache.ibatis.reflection.MetaObject;
|
||||||
|
import org.apache.ibatis.reflection.wrapper.ObjectWrapper;
|
||||||
|
import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lhc
|
||||||
|
* @version 1.0
|
||||||
|
* @className UpperCaseMapWrapperFactory
|
||||||
|
* @date 2025年03月28日 19:40
|
||||||
|
* @description 描述
|
||||||
|
*/
|
||||||
|
public class UpperCaseMapWrapperFactory implements ObjectWrapperFactory {
|
||||||
|
@Override
|
||||||
|
public boolean hasWrapperFor(Object object) {
|
||||||
|
return object instanceof Map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectWrapper getWrapperFor(MetaObject metaObject, Object object) {
|
||||||
|
return new UpperCaseMapWrapper(metaObject, (Map) object);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -156,7 +156,7 @@ public class ShiroServiceImpl implements ShiroService {
|
|||||||
public FtToken findByToken(String accessToken) {
|
public FtToken findByToken(String accessToken) {
|
||||||
FtToken osToken = new FtToken();
|
FtToken osToken = new FtToken();
|
||||||
// osToken.setToken(accessToken);
|
// osToken.setToken(accessToken);
|
||||||
Condition condition = Condition.creatCriteria().equal("TOKEN", accessToken).build();
|
Condition condition = Condition.creatCriteria().andEqual("TOKEN", accessToken).build();
|
||||||
Map<String, Object> map = baseMapper.selectOneByCondition("FT_TOKEN", condition);
|
Map<String, Object> map = baseMapper.selectOneByCondition("FT_TOKEN", condition);
|
||||||
osToken.setToken((String) map.get("TOKEN"));
|
osToken.setToken((String) map.get("TOKEN"));
|
||||||
osToken.setTokenId((String) map.get("TOKEN_ID"));
|
osToken.setTokenId((String) map.get("TOKEN_ID"));
|
||||||
|
|||||||
@@ -157,6 +157,9 @@
|
|||||||
select ${tableName}_seq.nextval
|
select ${tableName}_seq.nextval
|
||||||
from dual
|
from dual
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getHighGoSequence" resultType="java.lang.Object">
|
||||||
|
select ${tableName}_seq.nextval
|
||||||
|
</select>
|
||||||
<insert id="createSequence">
|
<insert id="createSequence">
|
||||||
CREATE
|
CREATE
|
||||||
SEQUENCE ${tableName}_seq
|
SEQUENCE ${tableName}_seq
|
||||||
@@ -167,6 +170,28 @@
|
|||||||
INCREMENT BY 1
|
INCREMENT BY 1
|
||||||
NOCACHE
|
NOCACHE
|
||||||
</insert>
|
</insert>
|
||||||
|
<insert id="createHighGoSequence">
|
||||||
|
CREATE SEQUENCE ${tableName}_seq
|
||||||
|
MINVALUE 1
|
||||||
|
NO MAXVALUE
|
||||||
|
START WITH ${lastId}
|
||||||
|
INCREMENT BY 1
|
||||||
|
CACHE 1;
|
||||||
|
</insert>
|
||||||
|
<select id="judgeHighGoSequenceExist" resultType="boolean">
|
||||||
|
SELECT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM pg_class
|
||||||
|
WHERE relkind = 'S'
|
||||||
|
AND relname = '${tableName}_seq'
|
||||||
|
AND pg_table_is_visible(oid)
|
||||||
|
);
|
||||||
|
</select>
|
||||||
|
<select id="judgeDamengSequenceExist" resultType="boolean">
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM SYSOBJECTS
|
||||||
|
WHERE NAME = '${tableName}_seq' AND SUBTYPE$ = 'SEQUENCE';
|
||||||
|
</select>
|
||||||
<select id="count" resultType="java.lang.Long">
|
<select id="count" resultType="java.lang.Long">
|
||||||
SELECT count(0) FROM ${tableName} ${sql}
|
SELECT count(0) FROM ${tableName} ${sql}
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
Reference in New Issue
Block a user