This commit is contained in:
wangjinlei
2024-09-29 16:58:05 +08:00
parent 9df9cf42ef
commit 4a84c9f21c
4 changed files with 109 additions and 14 deletions

View File

@@ -11,6 +11,7 @@ namespace app\api\controller;
use think\Controller;
use think\Db;
use think\Queue;
use think\Validate;
/**
* @title 领域接口
@@ -428,6 +429,31 @@ class Major extends Controller {
return jsonSuccess($re);
}
public function getJournalMajorInAll(){
$data = $this->request->post();
$rule = new Validate([
"journal_issn"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
//查询顶级
$list = $this->major_obj->where('pid', 0)->where("major_type", 0)->where('major_state', 0)->order('major_sort desc')->select();
foreach ($list as $k => $v) {
$selected = $this->major_to_journal_obj->where("major_id",$v['major_id'])->where("journal_issn",$data['journal_issn'])->where("mtj_state",0)->find();
$list[$k]['selected'] = $selected?1:0;
$cache_child = $this->getMajorChild($v,$data['journal_issn']);
if ($cache_child != null) {
$list[$k]['children'] = $cache_child;
}
}
$re['majors'] = $list;
return jsonSuccess($re);
}
/**
* @title 获取全部期刊
* @description 获取全部期刊
@@ -556,13 +582,17 @@ class Major extends Controller {
/**
* 获取领域子树
*/
private function getMajorChild($major) {
private function getMajorChild($major,$issn=null) {
$list = $this->major_obj->where('pid', $major['major_id'])->where("major_type", 0)->where('major_state', 0)->order("major_sort desc")->select();
if ($list == null) {
return null;
}
foreach ($list as $k => $v) {
$cache_child = $this->getMajorChild($v);
if($issn!=null){
$selected = $this->major_to_journal_obj->where("major_id",$v['major_id'])->where("journal_issn",$issn)->where("mtj_state",0)->find();
$list[$k]['selected'] = $selected?1:0;
}
$cache_child = $this->getMajorChild($v,$issn);
if ($cache_child != null) {
$list[$k]['children'] = $cache_child;
}
@@ -570,6 +600,22 @@ class Major extends Controller {
return $list;
}
public function getJournalsForMajor(){
$data = $this->request->post();
$rule = new Validate([
"major_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$issn_list = $this->major_to_journal_obj->where("major_id",$data['major_id'])->where("mtj_state",0)->column("journal_issn");
$list = $this->journal_obj->whereIn("issn",$issn_list)->select();
$re['list'] = $list;
return jsonSuccess($re);
}
/**
* 获取期刊领域树子集
* @param type $major