Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
kanyxmo committed Aug 24, 2022
2 parents 18f0bd9 + de1c39c commit b061aff
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion mine/Generator/ControllerGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ protected function getPk(): string
{
return SettingGenerateColumns::query()
->where('table_id', $this->model->id)
->where('is_pk', '1')
->where('is_pk', self::YES)
->value('column_name');
}

Expand Down
2 changes: 1 addition & 1 deletion mine/Generator/MapperGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ protected function getSearch(): string
$model = make(SettingGenerateColumnsService::class)->mapper->getModel();
$columns = $model->newQuery()
->where('table_id', $this->model->id)
->where('is_query', '1')
->where('is_query', self::YES)
->get(['column_name', 'column_comment', 'query_type'])->toArray();

$phpContent = '';
Expand Down
10 changes: 5 additions & 5 deletions mine/Generator/RequestGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public function setGenInfo(SettingGenerateTables $model): RequestGenerator
$this->columns = SettingGenerateColumns::query()
->where('table_id', $model->id)
->where(function($query) {
$query->where('is_insert', '1')
->orWhere('is_edit', '1')
->orWhere('is_required', '1');
$query->where('is_insert', self::YES)
->orWhere('is_edit', self::YES)
->orWhere('is_required', self::YES);
})
->orderByDesc('sort')
->get([ 'column_name', 'column_comment', 'is_insert', 'is_edit' ])->toArray();
Expand Down Expand Up @@ -198,10 +198,10 @@ protected function getRules(): string
$path = $this->getStubDir() . '/Request/rule.stub';

foreach ($this->columns as $column) {
if ($column['is_insert'] === '1') {
if ($column['is_insert'] == self::YES) {
$createCode .= $this->getRuleCode($column);
}
if ($column['is_edit'] === '1') {
if ($column['is_edit'] == self::YES) {
$updateCode .= $this->getRuleCode($column);
}
}
Expand Down
7 changes: 5 additions & 2 deletions mine/Generator/Traits/MapperGeneratorTraits.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ protected function getSearchPHPString($name, $mark, $comment): string
return <<<php
// {$comment}
if (isset(\$params['{$name}_min']) && isset(\$params['{$name}_max'])) {
\$query->whereBetween('{$name}', \$params['{$name}_min'], \$params['{$name}_max']);
if (isset(\$params['${name}']) && is_array(\$params['${name}']) && count(\$params['${name}']) == 2)
\$query->whereBetween(
'${name}',
[ \$params['${name}'][0], \$params['${name}'][1] ]
);
}
php;
Expand Down
6 changes: 4 additions & 2 deletions mine/Generator/VueIndexGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public function setGenInfo(SettingGenerateTables $model): VueIndexGenerator
$this->columns = SettingGenerateColumns::query()
->where('table_id', $model->id)->orderByDesc('sort')
->get([
'column_name', 'column_comment', 'allow_roles', 'options',
'is_query', 'is_pk', 'is_list', 'view_type', 'dict_type',
'column_name', 'column_comment', 'allow_roles', 'options', 'is_required', 'is_insert',
'is_edit', 'is_query', 'is_pk', 'is_list', 'view_type', 'dict_type',
]);

return $this->placeholderReplace();
Expand Down Expand Up @@ -179,6 +179,8 @@ protected function getCrud(): string
$options['rowSelection'] = [ 'showCheckedAll' => true ];
$options['searchLabelWidth'] = "'75px'";
$options['pk'] = "'".$this->getPk()."'";
$options['operationColumn'] = true;
$options['operationWidth'] = 160;
$options['api'] = $this->getBusinessEnName() . '.getList';
if (Str::contains($this->model->generate_menus, 'recycle')) {
$options['recycleApi'] = $this->getBusinessEnName() . '.getRecycleList';
Expand Down

0 comments on commit b061aff

Please sign in to comment.