门店端适配新表 及操盘手端工作台优化

This commit is contained in:
wong
2025-04-17 09:46:47 +08:00
parent 4f0ea36691
commit dbeb0aa559
23 changed files with 687 additions and 423 deletions

View File

@@ -162,19 +162,13 @@ class WorkbenchController extends Controller
$query->field('workbenchId,syncInterval,syncCount,syncType,startTime,endTime,accountType,devices,contentLibraries');
},
'user' => function($query) {
$query->field('username');
},
// 'groupPush' => function($query) {
// $query->field('workbenchId,pushInterval,pushContent,pushTime,devices,targetGroups');
// },
// 'groupCreate' => function($query) {
// $query->field('workbenchId,groupNamePrefix,maxGroups,membersPerGroup,devices,targetGroups');
// }
$query->field('id,username');
}
];
$list = Workbench::where($where)
->with($with)
->field('id,name,type,status,autoStart,createTime,updateTime')
->field('id,name,type,status,autoStart,userId,createTime,updateTime')
->order('id', 'desc')
->page($page, $limit)
->select()
@@ -195,6 +189,15 @@ class WorkbenchController extends Controller
$item->config = $item->momentsSync;
$item->config->devices = json_decode($item->config->devices, true);
$item->config->contentLibraries = json_decode($item->config->contentLibraries, true);
// 获取内容库名称
if (!empty($item->config->contentLibraries)) {
$libraryNames = \app\cunkebao\model\ContentLibrary::where('id', 'in', $item->config->contentLibraries)
->column('name');
$item->config->contentLibraryNames = $libraryNames;
} else {
$item->config->contentLibraryNames = [];
}
}
unset($item->momentsSync,$item->moments_sync);
break;
@@ -217,6 +220,9 @@ class WorkbenchController extends Controller
unset($item->groupCreate,$item->group_create);
break;
}
// 添加创建人名称
$item['creatorName'] = $item->user ? $item->user->username : '';
unset($item['user']); // 移除关联数据
return $item;
});
@@ -292,6 +298,7 @@ class WorkbenchController extends Controller
$workbench->config = $workbench->momentsSync;
$workbench->config->devices = json_decode($workbench->config->devices, true);
$workbench->config->contentLibraries = json_decode($workbench->config->contentLibraries, true);
unset($workbench->momentsSync,$workbench->moments_sync);
}
break;
case self::TYPE_GROUP_PUSH:

View File

@@ -20,6 +20,6 @@ class User extends Model
// 定义关联的工作台
public function workbench()
{
return $this->hasMany('Workbench', 'id', 'userId');
return $this->belongsTo('Workbench', 'id', 'userId');
}
}

View File

@@ -56,9 +56,11 @@ class Workbench extends Model
return $this->hasOne('WorkbenchGroupCreate', 'workbenchId', 'id');
}
// 用户关联
/**
* 用户关联
*/
public function user()
{
return $this->hasOne('User', 'id', 'userId');
return $this->belongsTo('User', 'userId', 'id');
}
}

View File

@@ -9,7 +9,6 @@ use think\Model;
*/
class WorkbenchAutoLike extends Model
{
protected $table = 'ck_workbench_auto_like';
protected $pk = 'id';
protected $name = 'workbench_auto_like';