Skip to content

Commit

Permalink
fix: Add PostgreSQLAdapter (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
fangzhengjin authored May 28, 2021
1 parent 76b2bed commit 3e9f859
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Empty file modified gradlew
100644 → 100755
Empty file.
35 changes: 35 additions & 0 deletions src/main/java/org/casbin/adapter/PostgreSQLAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.casbin.adapter;

import org.casbin.spring.boot.autoconfigure.properties.CasbinExceptionProperties;
import org.springframework.jdbc.core.JdbcTemplate;

/**
* @author fangzhengjin
* @version V1.0
* @title: PostgreSQLAdapter
* @package org.casbin.adapter
* @description:
* @date 2021/05/28 09:30
*/
public class PostgreSQLAdapter extends JdbcAdapter {

private final static String INIT_TABLE_SQL = "CREATE TABLE IF NOT EXISTS CASBIN_RULE (" +
" id SERIAL PRIMARY KEY, "+
" ptype varchar(255) NOT NULL," +
" v0 varchar(255) DEFAULT NULL," +
" v1 varchar(255) DEFAULT NULL," +
" v2 varchar(255) DEFAULT NULL," +
" v3 varchar(255) DEFAULT NULL," +
" v4 varchar(255) DEFAULT NULL," +
" v5 varchar(255) DEFAULT NULL" +
")";

public PostgreSQLAdapter(JdbcTemplate jdbcTemplate, CasbinExceptionProperties casbinExceptionProperties, boolean autoCreateTable) {
super(jdbcTemplate, casbinExceptionProperties, autoCreateTable);
}

@Override
protected String getInitTableSql() {
return INIT_TABLE_SQL;
}
}

0 comments on commit 3e9f859

Please sign in to comment.