multi-store/app/admin/lists/ChangeLogLists.php
mkm 1caae07bb9 feat(warehouse): 优化仓库产品编辑功能和变更日志
- 修改 WarehouseProductController 中的 edit 方法,增加 adminId 参数
- 更新 WarehouseProductLogic 中的 edit 方法,接收 adminId 参数
- 在 ChangeLogLists 中添加 admin_name 字段,关联管理员名称
- 调整 WarehouseProductLogic 中的 dec
2025-01-06 14:15:12 +08:00

71 lines
1.6 KiB
PHP

<?php
namespace app\admin\lists;
use app\admin\lists\BaseAdminDataLists;
use app\common\model\ChangeLog;
use app\common\lists\ListsSearchInterface;
use app\common\model\auth\Admin;
/**
* ChangeLog列表
* Class ChangeLogLists
* @package app\admin\lists
*/
class ChangeLogLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author admin
* @date 2025/01/06 10:03
*/
public function setSearch(): array
{
return [
'=' => ['model', 'link_id', 'nums', 'pm'],
'%like%' => ['mark','url'],
];
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author admin
* @date 2025/01/06 10:03
*/
public function lists(): array
{
return ChangeLog::where($this->searchWhere)
->field(['id', 'admin_id','model', 'link_id', 'nums', 'pm', 'url', 'mark'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item) {
if($item->admin_id){
$item->admin_name = Admin::where('id', $item->admin_id)->value('name');
}}
)
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author admin
* @date 2025/01/06 10:03
*/
public function count(): int
{
return ChangeLog::where($this->searchWhere)->count();
}
}