...
|
...
|
@@ -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');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|