feat: 配置了部分数据库内容

This commit is contained in:
2025-10-01 08:31:47 +00:00
parent dcd0a13f73
commit 1507bc220a
3 changed files with 139 additions and 27 deletions
+11 -11
View File
@@ -11,7 +11,7 @@
//["Options", "-SessionTicket"],
//["Options", "Compression"]
]
},
},*/
"listeners": [
{
//address: Ip address,0.0.0.0 by default
@@ -20,7 +20,7 @@
"port": 80,
//https: If true, use https for security,false by default
"https": false
},
} /*,
{
"address": "0.0.0.0",
"port": 443,
@@ -34,14 +34,14 @@
"ssl_conf": [
//["MinProtocol", "TLSv1.3"]
]
}
}*/
],
"db_clients": [
{
//name: Name of the client,'default' by default
"name": "default",
"name": "ouc_reminder_database",
//rdbms: Server type, postgresql,mysql or sqlite3, "postgresql" by default
"rdbms": "postgresql",
"rdbms": "mysql",
//filename: Sqlite3 db file name
//"filename":"",
//host: Server address,localhost by default
@@ -49,11 +49,11 @@
//port: Server port, 5432 by default
"port": 5432,
//dbname: Database name
"dbname": "test",
"dbname": "ouc_reminder",
//user: 'postgres' by default
"user": "",
"user": "pjh123",
//passwd: '' by default
"passwd": "",
"passwd": "123456",
//is_fast: false by default, if it is true, the client is faster but user can't call
//any synchronous interface of it.
"is_fast": false,
@@ -73,7 +73,7 @@
//For more information, see https://www.postgresql.org/docs/16/libpq-connect.html#LIBPQ-CONNECT-OPTIONS
//"connect_options": { "statement_timeout": "1s" }
}
],
], /*
"redis_clients": [
{
//name: Name of the client,'default' by default
@@ -108,7 +108,7 @@
"session_timeout": 0,
//string value of SameSite attribute of the Set-Cookie HTTP response header
//valid value is either 'Null' (default), 'Lax', 'Strict' or 'None'
"session_same_site" : "Null",
"session_same_site": "Null",
//session_cookie_key: The cookie key of the session, "JSESSIONID" by default
"session_cookie_key": "JSESSIONID",
//session_max_age: The max age of the session cookie, -1 by default
@@ -347,4 +347,4 @@
],
//custom_config: custom configuration for users. This object can be get by the app().getCustomConfig() method.
"custom_config": {}
}
}
+20 -16
View File
@@ -23,24 +23,28 @@
//convert: the value can be changed by a function call before it is stored into database or
//after it is read from database
"convert": {
"enabled": false,
"items":[{
"table": "user",
"column": "password",
"method": {
//after_db_read: name of the method which is called after reading from database, signature: void([const] std::shared_ptr [&])
"after_db_read": "decrypt_password",
//before_db_write: name of the method which is called before writing to database, signature: void([const] std::shared_ptr [&])
"before_db_write": "encrypt_password"
},
"includes": [
"\"file_local_search_path.h\"","<file_in_global_search_path.h>"
]
}]
"enabled": false,
"items": [
{
"table": "user",
"column": "password",
"method": {
//after_db_read: name of the method which is called after reading from database, signature: void([const] std::shared_ptr [&])
"after_db_read": "decrypt_password",
//before_db_write: name of the method which is called before writing to database, signature: void([const] std::shared_ptr [&])
"before_db_write": "encrypt_password"
},
"includes": [
"\"file_local_search_path.h\"",
"<file_in_global_search_path.h>"
]
}
]
},
"relationships": {
"enabled": false,
"items": [{
"items": [
{
"type": "has one",
"original_table_name": "products",
"original_table_alias": "product",
@@ -101,4 +105,4 @@
// generate_base_only: false by default. Set to true to avoid overwriting custom subclasses.
"generate_base_only": false
}
}
}
+108
View File
@@ -0,0 +1,108 @@
{
//rdbms: server type, postgresql,mysql or sqlite3
"rdbms": "postgresql",
//filename: sqlite3 db file name
//"filename":"",
//host: server address,localhost by default;
"host": "127.0.0.1",
//port: server port, 5432 by default;
"port": 5432,
//dbname: Database name;
"dbname": "mysql",
//schema: valid for postgreSQL, "public" by default;
"schema": "public",
//user: User name
"user": "pjh123",
//password or passwd: Password
"password": "123456",
//client_encoding: The character set used by drogon_ctl. it is empty string by default which
//means use the default character set.
//"client_encoding": "",
//table: An array of tables to be modelized. if the array is empty, all revealed tables are modelized.
"tables": [],
//convert: the value can be changed by a function call before it is stored into database or
//after it is read from database
"convert": {
"enabled": false,
"items": [
{
"table": "user",
"column": "password",
"method": {
//after_db_read: name of the method which is called after reading from database, signature: void([const] std::shared_ptr [&])
"after_db_read": "decrypt_password",
//before_db_write: name of the method which is called before writing to database, signature: void([const] std::shared_ptr [&])
"before_db_write": "encrypt_password"
},
"includes": [
"\"file_local_search_path.h\"",
"<file_in_global_search_path.h>"
]
}
]
},
"relationships": {
"enabled": false,
"items": [
{
"type": "has one",
"original_table_name": "products",
"original_table_alias": "product",
"original_key": "id",
"target_table_name": "skus",
"target_table_alias": "SKU",
"target_key": "product_id",
"enable_reverse": true
},
{
"type": "has many",
"original_table_name": "products",
"original_table_alias": "product",
"original_key": "id",
"target_table_name": "reviews",
"target_table_alias": "",
"target_key": "product_id",
"enable_reverse": true
},
{
"type": "many to many",
"original_table_name": "products",
"original_table_alias": "",
"original_key": "id",
"pivot_table": {
"table_name": "carts_products",
"original_key": "product_id",
"target_key": "cart_id"
},
"target_table_name": "carts",
"target_table_alias": "",
"target_key": "id",
"enable_reverse": true
}
]
},
"restful_api_controllers": {
"enabled": false,
// resource_uri: The URI to access the resource, the default value
// is '/*' in which the asterisk represents the table name.
// If this option is set to a empty string, the URI is composed of the namespaces and the class name.
"resource_uri": "/*",
// class_name: "Restful*Ctrl" by default, the asterisk represents the table name.
// This option can contain namespaces.
"class_name": "Restful*Ctrl",
// filters: an array of filter names.
"filters": [],
// db_client: the database client used by the controller. this option must be consistent with
// the configuration of the application.
"db_client": {
//name: Name of the client,'default' by default
"name": "default",
//is_fast:
"is_fast": false
},
// directory: The directory where the controller source files are stored.
"directory": "controllers",
// generate_base_only: false by default. Set to true to avoid overwriting custom subclasses.
"generate_base_only": false
}
}