作者 郭盛
1 个管道 的构建 通过 耗费 3 秒

修改删除新增领域

... ... @@ -508,13 +508,38 @@ class Teacher extends Api
if(empty($id)){
$this->error('缺少必要参数');
}
$data = Db::name('territory')
$res = Db::name('territory')
->where('id',$id)
->delete();
if(empty($data)){
$this->error('sql运行失败');
->find();
if($res['is_check'] == 1){
$data = Db::name('teacher')->where('user_id',$user_id)->find();
$territory_id = explode(',',$data['territory_id']);
foreach ($territory_id as $k =>$v){
if($v == $id){
unset($territory_id[$k]);
}
}
$upd_territory = implode(',',$territory_id);
$upd_teacher = Db::name('teacher')
->where('user_id',$user_id)
->update(['territory_id'=>$upd_territory]);
$data = Db::name('territory')
->where('id',$id)
->delete();
if(empty($upd_teacher) && empty($data)){
$this->error('sql运行失败');
}else{
$this->success('success');
}
}else{
$this->success('success');
$data = Db::name('territory')
->where('id',$id)
->delete();
if(empty($data)){
$this->error('sql运行失败');
}else{
$this->success('success');
}
}
}
... ...
... ... @@ -9433,7 +9433,7 @@
<div class="row mt0 footer">
<div class="col-md-6" align="left">
Generated on 2020-03-16 18:17:16 </div>
Generated on 2020-03-16 18:39:43 </div>
<div class="col-md-6" align="right">
<a href="https://www.fastadmin.net" target="_blank">FastAdmin</a>
</div>
... ...