lihai-oa/app/api/common.php

47 lines
1.1 KiB
PHP
Raw Normal View History

2023-10-24 15:17:16 +08:00
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/GPL-3.0
* @link https://www.gougucms.com
*/
2023-10-31 10:23:32 +08:00
use think\facade\Db;
2023-10-24 15:17:16 +08:00
//读取文章分类列表
function get_article_cate()
{
$cate = \think\facade\Db::name('ArticleCate')->order('create_time asc')->select()->toArray();
return $cate;
2023-10-31 10:23:32 +08:00
}
//写入日志
function add_project_log($uid,$module,$param,$old)
{
$log_data = [];
$key_array = ['id', 'create_time', 'update_time', 'delete_time', 'over_time', 'md_content'];
foreach ($param as $key => $value) {
if (!in_array($key, $key_array)) {
$log_data[] = array(
'module' => $module,
'field' => $key,
$module . '_id' => $param['id'],
'admin_id' => $uid,
'old_content' => $old[$key],
'new_content' => $value,
'create_time' => time(),
);
}
}
Db::name('ProjectLog')->strict(false)->field(true)->insertAll($log_data);
2023-10-31 15:34:42 +08:00
}
function isAuthProject($uid)
{
if($uid == 1){
return 1;
}
$map = [];
$map[] = ['name', '=', 'project_admin'];
$map[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',uids)")];
$count = Db::name('DataAuth')->where($map)->count();
return $count;
2023-10-24 15:17:16 +08:00
}