Files
cunkebao_v3/Server/application/cunkebao/controller/workbench/CommonFunctionsController.php
2026-01-05 09:34:48 +08:00

51 lines
1.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\cunkebao\controller\workbench;
use app\cunkebao\controller\BaseController;
use library\ResponseHelper;
use think\Db;
/**
* 常用功能控制器
*/
class CommonFunctionsController extends BaseController
{
/**
* 获取常用功能列表
* @return \think\response\Json
*/
public function getList()
{
try {
$companyId = $this->getUserInfo('companyId');
// 从数据库查询常用功能列表
$functions = Db::name('workbench_function')
->where('status', 1)
->order('sort ASC, id ASC')
->select();
// 处理数据判断是否显示New标签创建时间近1个月
$oneMonthAgo = time() - 30 * 24 * 60 * 60; // 30天前的时间戳
foreach ($functions as &$function) {
// 判断是否显示New标签创建时间在近1个月内
$function['isNew'] = ($function['createTime'] >= $oneMonthAgo) ? true : false;
$function['labels'] = json_decode($function['labels'],true);
}
unset($function);
return ResponseHelper::success([
'list' => $functions
]);
} catch (\Exception $e) {
return ResponseHelper::error('获取常用功能列表失败:' . $e->getMessage());
}
}
}