add postgresql support
This commit is contained in:
@@ -11,7 +11,10 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.apache.ibatis.mapping.DatabaseIdProvider;
|
||||
import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
|
||||
|
||||
import java.util.Properties;
|
||||
import javax.annotation.Resource;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@@ -51,9 +54,21 @@ public class MybatisPlusConfig {
|
||||
@Bean(name = "manageSqlSessionFactory")
|
||||
public MybatisSqlSessionFactoryBean manageSqlSessionFactory() throws Exception {
|
||||
MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
|
||||
DatabaseIdProvider databaseIdProvider = new VendorDatabaseIdProvider();
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("SQL Server", "sqlserver");
|
||||
properties.setProperty("DB2", "db2");
|
||||
properties.setProperty("Oracle", "oracle");
|
||||
properties.setProperty("MySQL", "mysql");
|
||||
properties.setProperty("PostgreSQL", "postgresql");
|
||||
properties.setProperty("Derby", "derby");
|
||||
properties.setProperty("HSQL", "hsqldb");
|
||||
properties.setProperty("H2", "h2");
|
||||
databaseIdProvider.setProperties(properties);
|
||||
sqlSessionFactoryBean.setDatabaseIdProvider(databaseIdProvider);
|
||||
sqlSessionFactoryBean.setDataSource(manageDatasource());
|
||||
sqlSessionFactoryBean.setPlugins(new SqlLogInterceptor(), paginationInterceptor);
|
||||
|
||||
|
||||
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:/mapper/manage/*Mapper.xml"));
|
||||
return sqlSessionFactoryBean;
|
||||
|
||||
@@ -18,15 +18,18 @@ import java.util.Map;
|
||||
*/
|
||||
public interface UserInfoMapper extends BaseMapper<UserInfo> {
|
||||
|
||||
@Select("show tables")
|
||||
@Select(value = "show tables")
|
||||
@Select(value = "SELECT table_name FROM information_schema.tables where table_schema = 'zyplayer_doc'", databaseId="postgresql")
|
||||
List<String> getTableList();
|
||||
|
||||
@Select("${sql}")
|
||||
List<String> executeSql(@Param("sql") String sql);
|
||||
|
||||
@Select("SHOW COLUMNS FROM ${tableName}")
|
||||
@Select(value = "SELECT * FROM information_schema.columns WHERE table_name = #{tableName} and table_schema = 'zyplayer_doc'", databaseId="postgresql")
|
||||
List<Map<String, Object>> getTableColumnList(@Param("tableName") String tableName);
|
||||
|
||||
@Select("SHOW INDEX FROM ${tableName}")
|
||||
@Select(value = "SELECT * FROM pg_catalog.pg_indexes WHERE tablename = #{tableName} and schemaname = 'zyplayer_doc'", databaseId="postgresql")
|
||||
List<Map<String, Object>> getTableIndexList(@Param("tableName") String tableName);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class UserAuthServiceImpl extends ServiceImpl<UserAuthMapper, UserAuth> i
|
||||
@Override
|
||||
public List<UserAuthInfo> getUserAuthSet(Long userId) {
|
||||
QueryWrapper<UserAuth> authWrapper = new QueryWrapper<>();
|
||||
authWrapper.eq("user_id", userId).eq("del_flag", "0");
|
||||
authWrapper.eq("user_id", userId).eq("del_flag", 0);
|
||||
List<UserAuth> userAuthList = this.list(authWrapper);
|
||||
if (CollectionUtils.isEmpty(userAuthList)) {
|
||||
return Collections.emptyList();
|
||||
|
||||
@@ -12,4 +12,12 @@
|
||||
set seq_no = b.rownum
|
||||
where a.parent_id = #{parentId} and a.space_id = #{spaceId};
|
||||
</update>
|
||||
<update id="updateChildrenSeq" databaseId="postgresql">
|
||||
WITH exceeded_wiki_page AS (
|
||||
select row_number() over() as rownum, * from wiki_page where parent_id = #{parentId} and space_id = #{spaceId} ORDER BY seq_no ASC, update_time DESC
|
||||
)
|
||||
UPDATE wiki_page SET seq_no = ewp.rownum
|
||||
FROM exceeded_wiki_page AS ewp
|
||||
WHERE wiki_page.id = ewp.id
|
||||
</update>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user