添加 infoTags 模型 v2
parent
f37b965cc4
commit
1c33404c45
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH'))
|
||||
exit('No direct script access allowed');
|
||||
|
||||
class Info_tags extends CI_Controller
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->permission->is_admin();
|
||||
//$this->output->enable_profiler(TRUE);
|
||||
$this->load->model('Information_model');
|
||||
$this->load->model('InfoTags_model');
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加标签
|
||||
*/
|
||||
public function add_tag()
|
||||
{
|
||||
$this->InfoTags_model->it_title = $this->input->get_post('title');
|
||||
$this->InfoTags_model->it_memo = $this->input->get_post('memo');
|
||||
$return = $this->InfoTags_model->add_tag();
|
||||
if ($return == 'success')
|
||||
{
|
||||
echo(json_encode(array(
|
||||
'status' => 1,
|
||||
'message' => '添加标签成功'
|
||||
)));
|
||||
}
|
||||
else if ($return == 'exist')
|
||||
{
|
||||
echo(json_encode(array(
|
||||
'status' => 2,
|
||||
'message' => '标签已存在'
|
||||
)));
|
||||
}
|
||||
else
|
||||
{
|
||||
echo(json_encode(array(
|
||||
'status' => -1,
|
||||
'message' => '添加标签失败'
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除标签
|
||||
*/
|
||||
public function remove_tag()
|
||||
{
|
||||
$this->InfoTags_model->it_title = $this->input->get_post('title');
|
||||
$return = $this->InfoTags_model->remove_tag();
|
||||
if ($return == 'success')
|
||||
{
|
||||
echo(json_encode(array(
|
||||
'status' => 1,
|
||||
'message' => '删除标签成功'
|
||||
)));
|
||||
}
|
||||
else
|
||||
{
|
||||
echo(json_encode(array(
|
||||
'status' => -1,
|
||||
'message' => '删除标签失败'
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加关联信息+标签
|
||||
*/
|
||||
public function add_tag_to_content()
|
||||
{
|
||||
$this->InfoTags_model->ic_id = $this->input->get_post('ic_id');
|
||||
$this->InfoTags_model->it_id = $this->input->get_post('it_id');
|
||||
$return = $this->InfoTags_model->add_tag_to_content();
|
||||
if ($return == 'success')
|
||||
{
|
||||
echo(json_encode(array(
|
||||
'status' => 1,
|
||||
'message' => '关联信息标签成功'
|
||||
)));
|
||||
}
|
||||
else if ($return == 'exist')
|
||||
{
|
||||
echo(json_encode(array(
|
||||
'status' => 2,
|
||||
'message' => '关联信息标签已存在'
|
||||
)));
|
||||
}
|
||||
else
|
||||
{
|
||||
echo(json_encode(array(
|
||||
'status' => -1,
|
||||
'message' => '关联信息标签失败'
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除关联信息+标签
|
||||
*/
|
||||
public function remove_tag_to_content()
|
||||
{
|
||||
$this->InfoTags_model->ic_id = $this->input->get_post('ic_id');
|
||||
$this->InfoTags_model->it_id = $this->input->get_post('it_id');
|
||||
$return = $this->InfoTags_model->remove_tag_to_content();
|
||||
if ($return == 'success')
|
||||
{
|
||||
echo(json_encode(array(
|
||||
'status' => 1,
|
||||
'message' => '移除关联信息标签成功'
|
||||
)));
|
||||
}
|
||||
else
|
||||
{
|
||||
echo(json_encode(array(
|
||||
'status' => -1,
|
||||
'message' => '移除关联信息标签失败'
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue