From ace142a41f2f9779f1a39d18ea73826772df463b Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Tue, 31 Oct 2023 10:23:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=A1=B9=E7=9B=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/common.php | 23 +++++++++++++++++++++++ app/project/validate/ProjectCheck.php | 21 ++------------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/app/api/common.php b/app/api/common.php index 14865da..1a55561 100644 --- a/app/api/common.php +++ b/app/api/common.php @@ -4,9 +4,32 @@ * @license https://opensource.org/licenses/GPL-3.0 * @link https://www.gougucms.com */ +use think\facade\Db; + //读取文章分类列表 function get_article_cate() { $cate = \think\facade\Db::name('ArticleCate')->order('create_time asc')->select()->toArray(); 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); } \ No newline at end of file diff --git a/app/project/validate/ProjectCheck.php b/app/project/validate/ProjectCheck.php index 845dd72..b278de9 100644 --- a/app/project/validate/ProjectCheck.php +++ b/app/project/validate/ProjectCheck.php @@ -12,7 +12,7 @@ class ProjectCheck extends Validate 'director_uid' => 'require', 'content' => 'require', 'code' => 'alphaNum|length:5,10|unique:project', - 'id' => 'require|checkProject' + 'id' => 'require' ]; protected $message = [ @@ -30,24 +30,7 @@ class ProjectCheck extends Validate protected $scene = [ '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; - } - } \ No newline at end of file