Skip to content

Commit 5fa26ff

Browse files
committed
feat: installer add getenv
1 parent 415f37c commit 5fa26ff

File tree

17 files changed

+1451
-117
lines changed

17 files changed

+1451
-117
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
3+
use Illuminate\Database\Schema\Blueprint;
4+
use Illuminate\Database\Migrations\Migration;
5+
6+
class ModifyMemberIdBig extends Migration
7+
{
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::table('member_user', function (Blueprint $table) {
16+
$table->bigIncrements('id')->change();
17+
});
18+
Schema::table('member_message', function (Blueprint $table) {
19+
$table->bigIncrements('id')->change();
20+
$table->unsignedBigInteger('userId')->change();
21+
$table->unsignedBigInteger('fromId')->change();
22+
});
23+
Schema::table('member_favorite', function (Blueprint $table) {
24+
$table->bigIncrements('id')->change();
25+
$table->unsignedBigInteger('userId')->change();
26+
});
27+
Schema::table('member_oauth', function (Blueprint $table) {
28+
$table->bigIncrements('id')->change();
29+
$table->unsignedBigInteger('memberUserId')->change();
30+
});
31+
Schema::table('member_upload', function (Blueprint $table) {
32+
$table->bigIncrements('id')->change();
33+
$table->unsignedBigInteger('userId')->change();
34+
$table->unsignedBigInteger('dataId')->change();
35+
});
36+
Schema::table('member_upload_category', function (Blueprint $table) {
37+
$table->bigIncrements('id')->change();
38+
$table->unsignedBigInteger('pid')->change();
39+
$table->unsignedBigInteger('userId')->change();
40+
});
41+
Schema::table('member_address', function (Blueprint $table) {
42+
$table->bigIncrements('id')->change();
43+
$table->unsignedBigInteger('memberUserId')->change();
44+
});
45+
Schema::table('member_money_cash', function (Blueprint $table) {
46+
$table->bigIncrements('id')->change();
47+
$table->unsignedBigInteger('memberUserId')->change();
48+
});
49+
Schema::table('member_money', function (Blueprint $table) {
50+
$table->bigIncrements('id')->change();
51+
$table->unsignedBigInteger('memberUserId')->change();
52+
});
53+
Schema::table('member_money_log', function (Blueprint $table) {
54+
$table->bigIncrements('id')->change();
55+
$table->unsignedBigInteger('memberUserId')->change();
56+
});
57+
Schema::table('member_credit', function (Blueprint $table) {
58+
$table->bigIncrements('id')->change();
59+
$table->unsignedBigInteger('memberUserId')->change();
60+
});
61+
Schema::table('member_credit_log', function (Blueprint $table) {
62+
$table->bigIncrements('id')->change();
63+
$table->unsignedBigInteger('memberUserId')->change();
64+
});
65+
Schema::table('member_money_charge_order', function (Blueprint $table) {
66+
$table->bigIncrements('id')->change();
67+
$table->unsignedBigInteger('memberUserId')->change();
68+
});
69+
Schema::table('member_vip_order', function (Blueprint $table) {
70+
$table->bigIncrements('id')->change();
71+
$table->unsignedBigInteger('memberUserId')->change();
72+
});
73+
Schema::table('member_deleted', function (Blueprint $table) {
74+
$table->bigIncrements('id')->change();
75+
});
76+
Schema::table('member_meta', function (Blueprint $table) {
77+
$table->bigIncrements('id')->change();
78+
$table->unsignedBigInteger('memberUserId')->change();
79+
});
80+
}
81+
82+
/**
83+
* Reverse the migrations.
84+
*
85+
* @return void
86+
*/
87+
public function down()
88+
{
89+
90+
}
91+
}

module/Member/Util/MemberMetaUtil.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ public static function set($memberUserId, $name, $value = null)
2222
'value' => $value,
2323
'updated_at' => Carbon::now()
2424
]) <= 0) {
25-
ModelUtil::insert('member_meta', array_merge($where, [
26-
'value' => $value,
27-
]));
25+
ModelUtil::transactionBegin();
26+
$one = ModelUtil::getWithLock('member_meta', $where);
27+
if (empty($one)) {
28+
ModelUtil::insert('member_meta', array_merge($where, [
29+
'value' => $value,
30+
]));
31+
}
32+
ModelUtil::transactionCommit();
2833
}
2934
}
3035
}

module/Vendor/Installer/function.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
define('INSTALL_APP', 'APP');
3737
}
3838
if (!defined('INSTALL_APP_NAME')) {
39-
if(defined('INSTALL_APP')){
39+
if (defined('INSTALL_APP')) {
4040
define('INSTALL_APP_NAME', INSTALL_APP);
41-
}else{
41+
} else {
4242
define('INSTALL_APP_NAME', 'APP');
4343
}
4444
}
@@ -98,6 +98,23 @@ function get_env_config($key, $default = '')
9898
if (isset($envConfig[$key])) {
9999
return $envConfig[$key];
100100
}
101+
$osEnvMap = [
102+
'db_host' => ['DB_HOST', 'MYSQL_HOST'],
103+
'db_name' => ['DB_DATABASE', 'MYSQL_DB'],
104+
'db_username' => ['DB_USERNAME', 'MYSQL_USER'],
105+
'db_password' => ['DB_PASSWORD', 'MYSQL_PASSWORD'],
106+
'db_prefix' => ['DB_PREFIX'],
107+
'admin_username' => ['ADMIN_USERNAME'],
108+
'admin_password' => ['ADMIN_PASSWORD'],
109+
];
110+
if (isset($osEnvMap[$key])) {
111+
foreach ($osEnvMap[$key] as $k) {
112+
$v = @getenv($k);
113+
if (!empty($v)) {
114+
return $v;
115+
}
116+
}
117+
}
101118
$envMap = [
102119
'db_host' => 'DB_HOST',
103120
'db_name' => 'DB_DATABASE',
@@ -108,7 +125,10 @@ function get_env_config($key, $default = '')
108125
'admin_password' => 'ADMIN_PASSWORD',
109126
];
110127
if (isset($envMap[$key])) {
111-
return env($envMap[$key], $default);
128+
$v = env($envMap[$key], null);
129+
if (!is_null($v)) {
130+
return $v;
131+
}
112132
}
113133
return $default;
114134
}

vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function compileTableExists()
3939
*/
4040
public function compileColumnExists()
4141
{
42-
return 'select column_name as column_name from information_schema.columns where table_schema = ? and table_name = ?';
42+
return 'select column_name as `column_name` from information_schema.columns where table_schema = ? and table_name = ?';
4343
}
4444

4545
/**

0 commit comments

Comments
 (0)