更新项目管理

This commit is contained in:
yaooo 2023-10-31 10:23:32 +08:00
parent 3dab0af11d
commit ace142a41f
2 changed files with 25 additions and 19 deletions

View File

@ -4,9 +4,32 @@
* @license https://opensource.org/licenses/GPL-3.0 * @license https://opensource.org/licenses/GPL-3.0
* @link https://www.gougucms.com * @link https://www.gougucms.com
*/ */
use think\facade\Db;
//读取文章分类列表 //读取文章分类列表
function get_article_cate() function get_article_cate()
{ {
$cate = \think\facade\Db::name('ArticleCate')->order('create_time asc')->select()->toArray(); $cate = \think\facade\Db::name('ArticleCate')->order('create_time asc')->select()->toArray();
return $cate; return $cate;
}
//写入日志
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);
} }

View File

@ -12,7 +12,7 @@ class ProjectCheck extends Validate
'director_uid' => 'require', 'director_uid' => 'require',
'content' => 'require', 'content' => 'require',
'code' => 'alphaNum|length:5,10|unique:project', 'code' => 'alphaNum|length:5,10|unique:project',
'id' => 'require|checkProject' 'id' => 'require'
]; ];
protected $message = [ protected $message = [
@ -30,24 +30,7 @@ class ProjectCheck extends Validate
protected $scene = [ protected $scene = [
'add' => ['name','start_time','end_time','director_uid','content','code'], 'add' => ['name','start_time','end_time','director_uid','content','code'],
'edit' => ['id', 'name','start_time','end_time','director_uid','content','code'] 'edit' => ['id']
]; ];
public function checkProject($id, $rule, $data)
{
$project = Db::name('project')->where([
'id' => $id
])->findOrEmpty();
if (empty($project)) {
return '项目不存在';
}
$oProject = Db::name('project')->where([
'name' => $data['name']
])->findOrEmpty();
if (!empty($oProject) && ($oProject['id'] != $id)) {
return '项目已存在';
}
return true;
}
} }