|
|
@ -52,7 +52,7 @@ class Api { |
|
|
|
* 修改分类目录 |
|
|
|
* 修改分类目录 |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function edit_category($token,$id,$name,$property = 0,$weight = 0,$description = '',$font_icon = ''){ |
|
|
|
public function edit_category($token,$id,$name,$property = 0,$weight = 0,$description = '',$font_icon = '',$fid = 0){ |
|
|
|
$this->auth($token); |
|
|
|
$this->auth($token); |
|
|
|
//如果id为空 |
|
|
|
//如果id为空 |
|
|
|
if( empty($id) ){ |
|
|
|
if( empty($id) ){ |
|
|
@ -62,15 +62,24 @@ class Api { |
|
|
|
elseif( empty($name ) ){ |
|
|
|
elseif( empty($name ) ){ |
|
|
|
$this->err_msg(-1004,'The category name cannot be empty!'); |
|
|
|
$this->err_msg(-1004,'The category name cannot be empty!'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//更新数据库 |
|
|
|
//更新数据库 |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
|
|
|
|
//根据分类ID查询改分类下面是否已经存在子分类,如果存在子分类了则不允许设置为子分类,实用情况:一级分类下存在二级分类,无法再将改一级分类修改为二级分类 |
|
|
|
|
|
|
|
$count = $this->db->count("on_categorys", [ |
|
|
|
|
|
|
|
"fid" => $id |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
if( $count > 0 ) { |
|
|
|
|
|
|
|
$this->err_msg(-2000,'修改失败,该分类下已存在子分类!'); |
|
|
|
|
|
|
|
} |
|
|
|
$data = [ |
|
|
|
$data = [ |
|
|
|
'name' => htmlspecialchars($name,ENT_QUOTES), |
|
|
|
'name' => htmlspecialchars($name,ENT_QUOTES), |
|
|
|
'up_time' => time(), |
|
|
|
'up_time' => time(), |
|
|
|
'weight' => $weight, |
|
|
|
'weight' => $weight, |
|
|
|
'property' => $property, |
|
|
|
'property' => $property, |
|
|
|
'description' => htmlspecialchars($description,ENT_QUOTES), |
|
|
|
'description' => htmlspecialchars($description,ENT_QUOTES), |
|
|
|
'font_icon' => $font_icon |
|
|
|
'font_icon' => $font_icon, |
|
|
|
|
|
|
|
'fid' => $fid |
|
|
|
]; |
|
|
|
]; |
|
|
|
$re = $this->db->update('on_categorys',$data,[ 'id' => $id]); |
|
|
|
$re = $this->db->update('on_categorys',$data,[ 'id' => $id]); |
|
|
|
//var_dump( $this->db->log() ); |
|
|
|
//var_dump( $this->db->log() ); |
|
|
|