测试userviewjob,编写user view的逻辑
parent
912240c873
commit
dd4e946254
@ -0,0 +1,16 @@
|
||||
package com.docus.server.common.db;
|
||||
|
||||
import com.baomidou.mybatisplus.core.incrementer.IKeyGenerator;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class KeyGenerator implements IKeyGenerator {
|
||||
public static String genId() {
|
||||
return UUID.randomUUID().toString().replace("-", "").toUpperCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String executeSql(String incrementerName) {
|
||||
return genId();
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package com.docus.server.common.db.type.handler;
|
||||
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
|
||||
import java.sql.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
//用于兼容gbase localdatetime 转换
|
||||
@MappedTypes(value = LocalDateTime.class)
|
||||
public class LocalDateTimeTypeHandler extends BaseTypeHandler<LocalDateTime> {
|
||||
|
||||
//驱动是否原生支持
|
||||
private Boolean isJdbcSupport;
|
||||
|
||||
private boolean getIsJdbcSupport(ResultSet rs, String columnName) {
|
||||
if (isJdbcSupport == null) {
|
||||
try {
|
||||
rs.getObject(columnName, LocalDateTime.class);
|
||||
isJdbcSupport = true;
|
||||
} catch (Exception e) {
|
||||
isJdbcSupport = false;
|
||||
}
|
||||
}
|
||||
return isJdbcSupport;
|
||||
}
|
||||
|
||||
private boolean getIsJdbcSupport(CallableStatement cs, int columnIndex) {
|
||||
if (isJdbcSupport == null) {
|
||||
try {
|
||||
cs.getObject(columnIndex, LocalDateTime.class);
|
||||
isJdbcSupport = true;
|
||||
} catch (Exception e) {
|
||||
isJdbcSupport = false;
|
||||
}
|
||||
}
|
||||
return isJdbcSupport;
|
||||
}
|
||||
|
||||
private boolean getIsJdbcSupport(ResultSet rs, int columnIndex) {
|
||||
if (isJdbcSupport == null) {
|
||||
try {
|
||||
rs.getObject(columnIndex, LocalDateTime.class);
|
||||
isJdbcSupport = true;
|
||||
} catch (Exception e) {
|
||||
isJdbcSupport = false;
|
||||
}
|
||||
}
|
||||
return isJdbcSupport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, LocalDateTime localDateTime, JdbcType jdbcType) throws SQLException {
|
||||
if (isJdbcSupport != null && isJdbcSupport) {
|
||||
ps.setObject(i, localDateTime);
|
||||
} else {
|
||||
ps.setObject(i, Timestamp.valueOf(localDateTime));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime getNullableResult(ResultSet resultSet, String columnName) throws SQLException {
|
||||
if (getIsJdbcSupport(resultSet, columnName)) {
|
||||
return resultSet.getObject(columnName, LocalDateTime.class);
|
||||
} else {
|
||||
Timestamp timestamp = resultSet.getTimestamp(columnName);
|
||||
return timestamp == null ? null : timestamp.toLocalDateTime();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime getNullableResult(ResultSet resultSet, int columnIndex) throws SQLException {
|
||||
if (getIsJdbcSupport(resultSet, columnIndex)) {
|
||||
return resultSet.getObject(columnIndex, LocalDateTime.class);
|
||||
} else {
|
||||
Timestamp timestamp = resultSet.getTimestamp(columnIndex);
|
||||
return timestamp == null ? null : timestamp.toLocalDateTime();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime getNullableResult(CallableStatement callableStatement, int columnIndex) throws SQLException {
|
||||
if (getIsJdbcSupport(callableStatement, columnIndex)) {
|
||||
return callableStatement.getObject(columnIndex, LocalDateTime.class);
|
||||
} else {
|
||||
Timestamp timestamp = callableStatement.getTimestamp(columnIndex);
|
||||
return timestamp == null ? null : timestamp.toLocalDateTime();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package com.docus.server.common.db.type.handler;
|
||||
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
|
||||
import java.sql.*;
|
||||
import java.time.LocalDate;
|
||||
|
||||
//用于兼容gbase LocalDate 转换
|
||||
@MappedTypes(value = LocalDate.class)
|
||||
public class LocalDateTypeHandler extends BaseTypeHandler<LocalDate> {
|
||||
|
||||
//驱动是否原生支持
|
||||
private Boolean isJdbcSupport;
|
||||
|
||||
private boolean getIsJdbcSupport(ResultSet rs, String columnName) {
|
||||
if (isJdbcSupport == null) {
|
||||
try {
|
||||
rs.getObject(columnName, LocalDate.class);
|
||||
isJdbcSupport = true;
|
||||
} catch (Exception e) {
|
||||
isJdbcSupport = false;
|
||||
}
|
||||
}
|
||||
return isJdbcSupport;
|
||||
}
|
||||
|
||||
private boolean getIsJdbcSupport(CallableStatement cs, int columnIndex) {
|
||||
if (isJdbcSupport == null) {
|
||||
try {
|
||||
cs.getObject(columnIndex, LocalDate.class);
|
||||
isJdbcSupport = true;
|
||||
} catch (Exception e) {
|
||||
isJdbcSupport = false;
|
||||
}
|
||||
}
|
||||
return isJdbcSupport;
|
||||
}
|
||||
|
||||
private boolean getIsJdbcSupport(ResultSet rs, int columnIndex) {
|
||||
if (isJdbcSupport == null) {
|
||||
try {
|
||||
rs.getObject(columnIndex, LocalDate.class);
|
||||
isJdbcSupport = true;
|
||||
} catch (Exception e) {
|
||||
isJdbcSupport = false;
|
||||
}
|
||||
}
|
||||
return isJdbcSupport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, LocalDate localDate, JdbcType jdbcType) throws SQLException {
|
||||
if (isJdbcSupport != null && isJdbcSupport) {
|
||||
ps.setObject(i, localDate);
|
||||
} else {
|
||||
ps.setObject(i, Date.valueOf(localDate));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate getNullableResult(ResultSet resultSet, String columnName) throws SQLException {
|
||||
if (getIsJdbcSupport(resultSet, columnName)) {
|
||||
return resultSet.getObject(columnName, LocalDate.class);
|
||||
} else {
|
||||
Date date = resultSet.getDate(columnName);
|
||||
return date == null ? null : date.toLocalDate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate getNullableResult(ResultSet resultSet, int columnIndex) throws SQLException {
|
||||
if (getIsJdbcSupport(resultSet, columnIndex)) {
|
||||
return resultSet.getObject(columnIndex, LocalDate.class);
|
||||
} else {
|
||||
Date date = resultSet.getDate(columnIndex);
|
||||
return date == null ? null : date.toLocalDate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate getNullableResult(CallableStatement callableStatement, int columnIndex) throws SQLException {
|
||||
if (getIsJdbcSupport(callableStatement, columnIndex)) {
|
||||
return callableStatement.getObject(columnIndex, LocalDate.class);
|
||||
} else {
|
||||
Date date = callableStatement.getDate(columnIndex);
|
||||
return date == null ? null : date.toLocalDate();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package com.docus.server.common.db.type.handler;
|
||||
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
|
||||
import java.sql.*;
|
||||
import java.time.LocalTime;
|
||||
|
||||
//用于兼容gbase LocalTime 转换
|
||||
@MappedTypes(value = LocalTime.class)
|
||||
public class LocalTimeTypeHandler extends BaseTypeHandler<LocalTime> {
|
||||
|
||||
//驱动是否原生支持
|
||||
private Boolean isJdbcSupport;
|
||||
|
||||
private boolean getIsJdbcSupport(ResultSet rs, String columnName) {
|
||||
if (isJdbcSupport == null) {
|
||||
try {
|
||||
rs.getObject(columnName, LocalTime.class);
|
||||
isJdbcSupport = true;
|
||||
} catch (Exception e) {
|
||||
isJdbcSupport = false;
|
||||
}
|
||||
}
|
||||
return isJdbcSupport;
|
||||
}
|
||||
|
||||
private boolean getIsJdbcSupport(CallableStatement cs, int columnIndex) {
|
||||
if (isJdbcSupport == null) {
|
||||
try {
|
||||
cs.getObject(columnIndex, LocalTime.class);
|
||||
isJdbcSupport = true;
|
||||
} catch (Exception e) {
|
||||
isJdbcSupport = false;
|
||||
}
|
||||
}
|
||||
return isJdbcSupport;
|
||||
}
|
||||
|
||||
private boolean getIsJdbcSupport(ResultSet rs, int columnIndex) {
|
||||
if (isJdbcSupport == null) {
|
||||
try {
|
||||
rs.getObject(columnIndex, LocalTime.class);
|
||||
isJdbcSupport = true;
|
||||
} catch (Exception e) {
|
||||
isJdbcSupport = false;
|
||||
}
|
||||
}
|
||||
return isJdbcSupport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, LocalTime LocalTime, JdbcType jdbcType) throws SQLException {
|
||||
if (isJdbcSupport != null && isJdbcSupport) {
|
||||
ps.setObject(i, LocalTime);
|
||||
} else {
|
||||
ps.setObject(i, Time.valueOf(LocalTime));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalTime getNullableResult(ResultSet resultSet, String columnName) throws SQLException {
|
||||
if (getIsJdbcSupport(resultSet, columnName)) {
|
||||
return resultSet.getObject(columnName, LocalTime.class);
|
||||
} else {
|
||||
Time time = resultSet.getTime(columnName);
|
||||
return time == null ? null : time.toLocalTime();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalTime getNullableResult(ResultSet resultSet, int columnIndex) throws SQLException {
|
||||
if (getIsJdbcSupport(resultSet, columnIndex)) {
|
||||
return resultSet.getObject(columnIndex, LocalTime.class);
|
||||
} else {
|
||||
Time time = resultSet.getTime(columnIndex);
|
||||
return time == null ? null : time.toLocalTime();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalTime getNullableResult(CallableStatement callableStatement, int columnIndex) throws SQLException {
|
||||
if (getIsJdbcSupport(callableStatement, columnIndex)) {
|
||||
return callableStatement.getObject(columnIndex, LocalTime.class);
|
||||
} else {
|
||||
Time time = callableStatement.getTime(columnIndex);
|
||||
return time == null ? null : time.toLocalTime();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue