Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meibuyu-rpc
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
without authentication
meibuyu-rpc
Commits
fdf170ec
Commit
fdf170ec
authored
Oct 27, 2020
by
王源
🎧
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hotfix' into test
parents
9af28c44
fd96b588
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
28 deletions
+12
-28
MakeModelCommand.php
src/Command/MakeModelCommand.php
+2
-14
model.stub
src/Command/stubs/model.stub
+7
-14
SpecialUserId.php
src/Constants/SpecialUserId.php
+3
-0
No files found.
src/Command/MakeModelCommand.php
View file @
fdf170ec
...
@@ -308,7 +308,6 @@ class MakeModelCommand extends HyperfCommand
...
@@ -308,7 +308,6 @@ class MakeModelCommand extends HyperfCommand
$filterFields
=
[
"id"
,
"created_at"
,
"updated_at"
,
"deleted_at"
];
$filterFields
=
[
"id"
,
"created_at"
,
"updated_at"
,
"deleted_at"
];
$fillAble
=
''
;
$fillAble
=
''
;
$properties
=
''
;
$properties
=
''
;
$casts
=
''
;
$timestamps
=
0
;
$timestamps
=
0
;
$softDelete
=
false
;
$softDelete
=
false
;
$list
=
$info
[
'fields'
];
$list
=
$info
[
'fields'
];
...
@@ -348,26 +347,15 @@ class MakeModelCommand extends HyperfCommand
...
@@ -348,26 +347,15 @@ class MakeModelCommand extends HyperfCommand
];
];
$properties
.=
" * @property "
.
(
isset
(
$pc
[
$v
[
'data_type'
]])
?
$pc
[
$v
[
'data_type'
]]
:
"string"
)
.
" $"
.
$name
.
(
$v
[
'column_comment'
]
?
" "
.
$v
[
'column_comment'
]
:
""
)
.
"
\n
"
;
$properties
.=
" * @property "
.
(
isset
(
$pc
[
$v
[
'data_type'
]])
?
$pc
[
$v
[
'data_type'
]]
:
"string"
)
.
" $"
.
$name
.
(
$v
[
'column_comment'
]
?
" "
.
$v
[
'column_comment'
]
:
""
)
.
"
\n
"
;
if
(
$name
==
'created_at'
||
$name
==
'updated_at'
)
{
if
(
$name
==
'created_at'
||
$name
==
'updated_at'
)
{
$casts
.=
"
\t\t
'"
.
$name
.
"'=>'datetime',
\n
"
;
$timestamps
++
;
$timestamps
++
;
}
}
if
(
$name
==
'deleted_at'
)
{
if
(
$name
==
'deleted_at'
)
{
$casts
.=
"
\t\t
'"
.
$name
.
"'=>'datetime',
\n
"
;
$softDelete
=
true
;
$softDelete
=
true
;
}
}
if
(
in_array
(
$name
,
$filterFields
))
{
if
(
in_array
(
$name
,
$filterFields
))
{
continue
;
continue
;
}
}
$fillAble
.=
"
\t\t
'"
.
$name
.
"',"
.
"
\n
"
;
$fillAble
.=
"
\t\t
'"
.
$name
.
"',"
.
"
\n
"
;
if
(
isset
(
$this
->
cc
[
$v
[
'data_type'
]])
&&
$this
->
cc
[
$v
[
'data_type'
]]
!=
'string'
)
{
if
(
$this
->
cc
[
$v
[
'data_type'
]]
==
'timestamp'
)
{
$casts
.=
"
\t\t
'"
.
$name
.
"'=>'datetime',
\n
"
;
}
else
if
(
$this
->
cc
[
$v
[
'data_type'
]]
==
'decimal'
)
{
$casts
.=
"
\t\t
'"
.
$name
.
"'=>'float',
\n
"
;
}
else
{
$casts
.=
"
\t\t
'"
.
$name
.
"'=>'"
.
$this
->
cc
[
$v
[
'data_type'
]]
.
"',
\n
"
;
}
}
}
}
$relation
=
''
;
$relation
=
''
;
if
(
isset
(
$info
[
'relations'
])
&&
$info
[
'relations'
])
{
if
(
isset
(
$info
[
'relations'
])
&&
$info
[
'relations'
])
{
...
@@ -414,8 +402,8 @@ class MakeModelCommand extends HyperfCommand
...
@@ -414,8 +402,8 @@ class MakeModelCommand extends HyperfCommand
$sd
=
"use SoftDeletes;
\n
"
;
$sd
=
"use SoftDeletes;
\n
"
;
$sdn
=
"use Hyperf\Database\Model\SoftDeletes;
\n
"
;
$sdn
=
"use Hyperf\Database\Model\SoftDeletes;
\n
"
;
}
}
$patterns
=
[
'%namespace%'
,
"%ClassName%"
,
"%fillAble%"
,
"%casts%"
,
'%relations%'
,
'%timestamps%'
,
'%properties%'
,
'%SoftDelete%'
];
$patterns
=
[
'%namespace%'
,
"%ClassName%"
,
"%fillAble%"
,
'%relations%'
,
'%timestamps%'
,
'%properties%'
,
'%SoftDelete%'
];
$replacements
=
[
$sdn
,
$modelName
,
$fillAble
,
$
casts
,
$
relation
,
(
$timestamps
==
2
?
'true'
:
'false'
),
$properties
,
$sd
];
$replacements
=
[
$sdn
,
$modelName
,
$fillAble
,
$relation
,
(
$timestamps
==
2
?
'true'
:
'false'
),
$properties
,
$sd
];
$content
=
$this
->
buildField
(
$patterns
,
$replacements
,
$content
);
$content
=
$this
->
buildField
(
$patterns
,
$replacements
,
$content
);
$this
->
writeToFile
(
$file
,
$content
);
$this
->
writeToFile
(
$file
,
$content
);
...
...
src/Command/stubs/model.stub
View file @
fdf170ec
...
@@ -19,27 +19,20 @@ namespace App\Model;
...
@@ -19,27 +19,20 @@ namespace App\Model;
class
%
ClassName
%
extends
Model
class
%
ClassName
%
extends
Model
{
{
%
SoftDelete
%
%
SoftDelete
%
/**
/**
* 可写入数据的字段.
* 是否使用时间戳管理
* @var array
* @var bool
*/
*/
protected
$fillable
=
[
public
$timestamps
=
%
timestamps
%
;
%
fillAble
%
];
/**
/**
*
字段转换数据类型的字段
*
可写入数据的字段.
* @var array
* @var array
*/
*/
protected
$
casts
=
[
protected
$
fillable
=
[
%
casts
%
%
fillAble
%
];
];
/**
* 是否使用时间戳管理
* @var bool
*/
public
$timestamps
=
%
timestamps
%
;
%
relations
%
%
relations
%
}
}
src/Constants/SpecialUserId.php
View file @
fdf170ec
...
@@ -13,7 +13,10 @@ class SpecialUserId
...
@@ -13,7 +13,10 @@ class SpecialUserId
const
BOSS
=
38
;
// 王大抗
const
BOSS
=
38
;
// 王大抗
const
ZHANG_TING_TING
=
83
;
// 张婷婷
const
ZHANG_TING_TING
=
83
;
// 张婷婷
const
MA_BAO_TONG
=
84
;
// 马宝同
const
CAI_YA_XIANG
=
85
;
// 蔡亚祥
const
CAI_YA_XIANG
=
85
;
// 蔡亚祥
const
CAI_HONG_SHAN
=
86
;
// 蔡红山
const
CAI_HONG_SHAN
=
86
;
// 蔡红山
const
ZHAN_YONG_YONG
=
87
;
// 詹永勇
const
BAO_SHI_FANG
=
322
;
// 鲍诗芳
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment