测试问题修改

This commit is contained in:
chengxl
2025-11-07 16:49:46 +08:00
parent 33630f9f0d
commit 667beda16b

View File

@@ -91,11 +91,11 @@ class Contribute extends Base
return json_encode(['status' => 6,'msg' => 'The article title is empty']);
}
//查询标题是否存在
$aWhere += ['title' => trim($aData['title']),'state' => ['<>',3]];
$aArticle = Db::name('article')->field('article_id')->where($aWhere)->find();
if(!empty($aArticle)){
return json_encode(['code' => 7, 'msg' => 'Warning: you are re-submitting the article!']);
}
// $aWhere += ['title' => trim($aData['title']),'state' => ['<>',3]];
// $aArticle = Db::name('article')->field('article_id')->where($aWhere)->find();
// if(!empty($aArticle)){
// return json_encode(['code' => 7, 'msg' => 'Warning: you are re-submitting the article!']);
// }
//数据入库
$aData += $aParam;
$result = $this->_addData($aData);
@@ -132,7 +132,7 @@ class Contribute extends Base
$sKeyWords = empty($aParam['keywords']) ? '' : $aParam['keywords'];
if(!empty($sKeyWords)){
$aInsert['keywords'] = is_array($sKeyWords) ? implode(',', $sKeyWords) : $sKeyWords;
$aInsert['keywords'] = is_string($aInsert['keywords']) ? strip_tags($aInsert['keywords']) : '';
$aInsert['keywords'] = is_string($aInsert['keywords']) ? $aInsert['keywords'] : '';
}
// }
//摘要
@@ -205,11 +205,58 @@ class Contribute extends Base
}
}
//作者单位
$iArticleId = empty($iArticleId) ? $iUpdateArticleId : $iArticleId;
$aCompany = empty($aParam['company']) ? [] : $aParam['company'];
//处理作者
$aCompanyId = $aAuthor = [];//作者机构ID
if(!empty($aParam['author'])){
$aAuthor = $aParam['author'];
foreach ($aAuthor as $key => $value) {
if(empty($iArticleId)){
break;
}
//处理作者名字
$aName = empty($value['name']) ? [] : explode(' ', $value['name']);
if(empty($aName)){
continue;
}
//名字拆分
$sOldLastName = array_pop($aName);
$letters = [
'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z'
];
if(in_array(strtolower($sOldLastName), $letters)){
$value['company_id'] = [$sOldLastName];
$sLastName = array_pop($aName);
if(!empty($value['superscript'])){
$value['is_super'] = strpos($value['superscript'], '1') !== false ? 1 : 0;
$value['superscript'] = $sOldLastName.$value['superscript'];
}
if(!empty($aCompany)){
}else{
$sLastName = $sOldLastName;
}
$value['firstname'] = empty($aName) ? '' : trim(implode(' ', $aName));
if(empty($value['firstname'])){
continue;
}
if(ctype_upper($value['firstname'][0]) == false){
continue;
}
$value['lastname'] = $sLastName;
$aAuthor[$key] = $value;
if(!empty($value['company_id'])){
$aCompanyId[] = implode(',', $value['company_id']);
}
}
}
$aCompanyId = empty($aCompanyId) ? [] : array_unique(explode(',', implode(',', $aCompanyId)));
//文章机构
$iArticleId = empty($iArticleId) ? $iUpdateArticleId : $iArticleId;
if(!empty($aCompanyId)){
$aCompany = empty($aParam['company']) ? [] : $aParam['company'];
$aWhere = ['article_id' => $iArticleId,'state' => 0];
$aOrgan = Db::name('article_organ')->field('organ_id,organ_name,sort')->where($aWhere)->select();
$aOrganName = empty($aOrgan) ? [] : array_column($aOrgan, 'organ_name');
@@ -220,18 +267,16 @@ class Contribute extends Base
if(empty($value)){
continue;
}
if(!in_array($key, $aCompanyId)){
continue;
}
$sName = trim(trim(trim($value,'*'),'#'));
if(in_array($sName, $aOrganName)){
continue;
}
if(empty($iMaxSort)){
$iSort = $key;
$aSort[$key] = $key;
}else{
$iMaxSort++;
$iSort = $iMaxSort;
$aSort[$key] = $iMaxSort;
}
$iMaxSort++;
$iSort = $iMaxSort;
$aSort[$key] = $iMaxSort;
$sName = is_string($sName) ? strip_tags($sName) : '';
if(empty($sName)){
continue;
@@ -250,8 +295,7 @@ class Contribute extends Base
}
//处理作者
$aAuthorData = $aAuthorOrgn = [];
if(!empty($aParam['author'])){
$aAuthor = $aParam['author'];
if(!empty($aAuthor)){
//通讯作者
$aCorresponding = empty($aParam['corresponding']) ? [] : array_column($aParam['corresponding'], null,'name');
//查询文章作者
@@ -260,19 +304,13 @@ class Contribute extends Base
$aAuthorNameList = empty($aAuthorList) ? [] : array_column($aAuthorList, 'firstname');
$iMaxSort = empty($aAuthorList) ? 0 : max(array_column($aAuthorList, 'sort'));
foreach ($aAuthor as $key => $value) {
if(empty($iArticleId)){
break;
}
//处理作者名字
$aName = empty($value['name']) ? [] : explode(' ', $value['name']);
if(empty($aName)){
//处理作者名
if(empty($value['firstname'])){
continue;
}
//名字拆分
$sLastName = array_pop($aName);
$value['firstname'] = empty($aName) ? '' : trim(implode(' ', $aName));
$value['lastname'] = $sLastName;
if(ctype_upper($value['firstname'][0]) == false){
continue;
}
//处理作者机构单位关联
$aCountry = [];
if(!empty($value['company_id'])){
@@ -288,6 +326,7 @@ class Contribute extends Base
if(!empty($sOrganName)){
$sOrganName = str_replace([', ',''], ',', $sOrganName);
$aOrganName = explode(',',$sOrganName);
$aCountry[] = empty($aOrganName) ? '' : strtolower(end($aOrganName));
}
$aAuthorOrgn[] = ['article_id' => $iArticleId,'organ_id' => $iOrgnId,'art_aut_id' => $value['firstname']];
@@ -320,10 +359,10 @@ class Contribute extends Base
unset($value['name'],$value['company_id']);
$iMaxSort++;
$value['sort'] = $iMaxSort;
$value['country'] = empty($value['country']) ? '' : ucfirst(str_replace(['Pr '], '', $value['country']));
$aAuthorData[] = $value;
}
}
if(!empty($aAuthorData)){
$author_result = DB::name('article_author')->insertAll($aAuthorData);
if(empty($author_result)){