批量提交

This commit is contained in:
2025-04-25 17:27:26 +08:00
parent 9a51adf2e8
commit 1a6fc7af64
64 changed files with 6208 additions and 276 deletions
+37
View File
@@ -0,0 +1,37 @@
<?php
/**
* 后台管理系统
*/
namespace app\admin\model;
use think\Model;
use think\facade\App;
class Base extends Model{
public function logs($data=null,$fileName=''){
if(is_null($data) || is_null($fileName)){
return false;
}
//获取Runtime路径
$path = App::getRuntimePath() . 'logs' . DIRECTORY_SEPARATOR;
if(!is_dir($path)){
$mkdir_re = mkdir($path,0777,TRUE);
if(!$mkdir_re){
$this -> logs($data,$fileName);
}
}
$info = ['data'=>$data];
$content = json_encode($info, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . PHP_EOL;
if(empty($fileName)){
$filePath = $path . "/" . date("Ymd",time()).'.info.log';
}else{
$filePath = $path . "/" . $fileName . '.info.log';
}
$time = "[".date("Y-m-d H:i:s",time())."]";
$re = file_put_contents($filePath, $time." ".$content , FILE_APPEND);
if(!$re){
$this -> logs($data,$fileName);
}else{
return true;
}
}
}
+43
View File
@@ -0,0 +1,43 @@
<?php
/**
* 配置表
*/
namespace app\admin\model;
use app\admin\model\Base;
class YzAdminConfig extends Base{
protected $pk = 'config_id';
/**
* 列出全部配置,key对应value
*/
public function getAll(){
$aList = static::where('config_status',1)->order('config_sort DESC')->select()->toArray();
if(empty($aList)){
return [];
}else{
$return = [];
foreach($aList as $k=>$v){
$return[$v['config_name']] = $v['config_value'];
}
}
return $return;
}
/**
* 多条数据更新
*/
public function updateAll($data){
$lists = static::order('config_sort DESC,config_id')->select()->toArray();
if(empty($lists)){
return false;
}else{
foreach($lists as &$lists_v){
$lists_v['config_value'] = $data[$lists_v['config_name']];
}
$save = static::saveAll($lists);
if(empty($save)){
return false;
}
}
return true;
}
}