Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/mine-helpers/src/FastBuilderWhere.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,32 @@ public function __construct(
private readonly array $params,
) {}

public function eq(string $column, null|string $key = null): self
public function eq(string $column, ?string $key = null): self
{
return $this->buildOperator('=', $column, $key);
}

public function lt(string $column, null|string $key = null): self
public function lt(string $column, ?string $key = null): self
{
return $this->buildOperator('>', $column, $key);
}

public function ne(string $column, null|string $key = null): self
public function ne(string $column, ?string $key = null): self
{
return $this->buildOperator('<>', $column, $key);
}

public function le(string $column, null|string $key = null): self
public function le(string $column, ?string $key = null): self
{
return $this->buildOperator('<=', $column, $key);
}

public function ge(string $column, null|string $key = null): self
public function ge(string $column, ?string $key = null): self
{
return $this->buildOperator('>=', $column, $key);
}

public function gt(string $column, null|string $key = null): self
public function gt(string $column, ?string $key = null): self
{
return $this->buildOperator('>', $column, $key);
}
Expand Down Expand Up @@ -114,7 +114,7 @@ public function getBuilder(): Builder|ModelBuilder
return $this->builder;
}

private function buildOperator(string $operator, string $column, null|string $key): self
private function buildOperator(string $operator, string $column, ?string $key): self
{
return $this->where(
$column,
Expand All @@ -125,18 +125,18 @@ function (Builder|ModelBuilder $builder, mixed $value) use ($operator, $column)
);
}

private function where(string $column, \Closure $closure, null|string $key): self
private function where(string $column, \Closure $closure, ?string $key): self
{
$this->builder->when(Arr::get($this->params, $this->getKey($column, $key)), $closure);
return $this;
}

private function getKey(string $column, null|string $key): string
private function getKey(string $column, ?string $key): string
{
return $key ?: $column;
}

private function getRangeValues(array|string $keys): null|array
private function getRangeValues(array|string $keys): ?array
{
if (is_string($keys)) {
return Arr::get($this->params, $keys);
Expand Down
6 changes: 3 additions & 3 deletions src/mine-service/src/Annotation/ComponentCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@ public static function collectOverride(string $class, $override): void
static::$container['override'][$class] = $override;
}

public static function getComponent(null|string $component = null): null|array|string
public static function getComponent(?string $component = null): null|array|string
{
if ($component) {
return static::$container['component'][$component] ?? null;
}
return static::$container['component'];
}

public static function getPostConstruct(null|string $component = null): null|array|string
public static function getPostConstruct(?string $component = null): null|array|string
{
if ($component) {
return static::$container['postConstruct'][$component] ?? null;
}
return static::$container['postConstruct'];
}

public static function getOverride(null|string $component = null): null|array|string
public static function getOverride(?string $component = null): null|array|string
{
if ($component) {
return static::$container['override'][$component] ?? null;
Expand Down
4 changes: 2 additions & 2 deletions src/mine-service/src/Contract/SaveOrUpdateDaoContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface SaveOrUpdateDaoContract
* @return T
* @throws ServiceException
*/
public function saveOrUpdate(array $data, null|array $where = null): Model;
public function saveOrUpdate(array $data, ?array $where = null): Model;

/**
* 批量插入更新.
Expand All @@ -40,7 +40,7 @@ public function saveOrUpdate(array $data, null|array $where = null): Model;
*/
public function batchSaveOrUpdate(
array $data,
null|array $whereKeys = null,
?array $whereKeys = null,
int $batchSize = 0
): Collection;
}
2 changes: 1 addition & 1 deletion src/mine-service/src/Contract/UpdateDaoContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface UpdateDaoContract
* @return T
* @throws ServiceException
*/
public function save(array $data, null|array $withs = null): Model;
public function save(array $data, ?array $withs = null): Model;

/**
* 批量插入
Expand Down
4 changes: 2 additions & 2 deletions src/mine-service/src/Traits/SaveOrUpdateDaoTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
trait SaveOrUpdateDaoTrait
{
public function saveOrUpdate(array $data, null|array $where = null): Model
public function saveOrUpdate(array $data, ?array $where = null): Model
{
$keyName = $this->getModelInstance()->getKeyName();
if ($where === null) {
Expand All @@ -39,7 +39,7 @@ public function saveOrUpdate(array $data, null|array $where = null): Model

public function batchSaveOrUpdate(
array $data,
null|array $whereKeys = null,
?array $whereKeys = null,
int $batchSize = 0
): Collection {
return Db::transaction(function () use ($data, $whereKeys) {
Expand Down
2 changes: 1 addition & 1 deletion src/mine-service/src/Traits/UpdateDaoTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
trait UpdateDaoTrait
{
public function save(array $data, null|array $withs = null): Model
public function save(array $data, ?array $withs = null): Model
{
return Db::transaction(function () use ($data, $withs) {
$modelClass = $this->getModel();
Expand Down
9 changes: 4 additions & 5 deletions src/office/src/Excel/XlsWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,18 @@ public function export(string $filename, array|\Closure $closure, \Closure $call
$columnFormat = new Format($fileObject->getHandle());
$rowFormat = new Format($fileObject->getHandle());

$index = 0;
for ($i = 0; $i < count($columnField); ++$i) {
$columnNumber = chr($i) . '1';
$i = 0;
foreach ($this->property as $index => $item) {
$fileObject->setColumn(
sprintf('%s1:%s1', $this->getColumnIndex($i), $this->getColumnIndex($i)),
$this->property[$index]['width'] ?? mb_strlen($columnName[$index]) * 5,
$this->property[$index]['width'] ?? mb_strlen($columnName[$i]) * 5,
$columnFormat->align($this->property[$index]['align'] ? $aligns[$this->property[$index]['align']] : $aligns['left'])
->background($this->property[$index]['bgColor'] ?? Format::COLOR_WHITE)
->border(Format::BORDER_THIN)
->fontColor($this->property[$index]['color'] ?? Format::COLOR_BLACK)
->toResource()
);
++$index;
++$i;
}

// 表头加样式
Expand Down