fixed 修改Tdk多余内容和更新excel导入

This commit is contained in:
lwh 2023-06-29 19:18:23 +08:00
parent e873f8c300
commit ad376c5bb8
2 changed files with 2 additions and 65 deletions

View File

@ -18,71 +18,6 @@ use think\facade\Env;
class Tdk extends BaseController
{
public function createXmd()
{
$table_all = Db::query('SHOW TABLES');
$arr = [];
$match = ['_copy', '_copy1', 'demo', '_lpf', '_20'];
$res_str = '';
foreach ($table_all as $key => $it) {
$item = $it['Tables_in_shop_uniapp'];
$currentMatch = '';
foreach ($match as $matchKey => $matchItem) {
if (stripos($item, $matchItem) === false) {
$currentMatch = '';
} else {
$currentMatch = $item;
break;
}
}
if ($item != $currentMatch) {
$arr[$item] = [
'comment' => $table_info = Db::query('SHOW TABLE STATUS LIKE ' . "'" . $item . "'")[0]['Comment'],
'children' => Db::query('SHOW FULL COLUMNS FROM `' . $item . '`')
];
}
}
function createXmdStr(&$res_str, $arr)
{
foreach ($arr as $key => &$item) {
if ($item['comment'] != '') {
$res_str .= "\n{$key}\n\t" . $item['comment'];
if ($item['children']) {
foreach ($item['children'] as $childKey => &$childItem) {
if ($childItem['Comment'] == '') {
$res_str .= "\n\t\t{$childItem['Field']}";
} else {
$childItem['Comment'] = str_replace(",", '', $childItem['Comment']);
$childItem['Comment'] = str_replace("]", ')', $childItem['Comment']);
$childItem['Comment'] = str_replace("[", '(', $childItem['Comment']);
$res_str .= "\n\t\t{$childItem['Field']}\n\t\t\t{$childItem['Comment']}";
}
}
}
} else {
$res_str .= "\n{$key}";
if ($item['children']) {
foreach ($item['children'] as $childKey => &$childItem) {
if ($childItem['Comment'] == '') {
$res_str .= "\n\t{$childItem['Field']}";
} else {
$childItem['Comment'] = str_replace(",", '', $childItem['Comment']);
$childItem['Comment'] = str_replace("]", ')', $childItem['Comment']);
$childItem['Comment'] = str_replace("[", '(', $childItem['Comment']);
$res_str .= "\n\t{$childItem['Field']}\n\t\t{$childItem['Comment']}";
}
}
}
}
}
}
createXmdStr($res_str, $arr);
echo $res_str;
return '';
}
/**
* 获取网站tdk详情
*/
@ -92,6 +27,8 @@ class Tdk extends BaseController
$this->validate($params, ['tdk_type' => 'require']);
// $params[]
$find = ModelTdk::field([
'tdk_id',
'tdk_type',