public function addFollow(){
$follow_obj = D('Follow');
if(empty($_POST['m_id']) || empty($_POST['g_id'])){
apiResponse('error','您未登录或商品ID为空!');
}
$where['m_id'] = I('post.m_id');
$where['g_id'] = I('post.g_id');
//判断是否关注过
$follow = $follow_obj->findFollow($where);
if($follow){
apiResponse('error','您已经关注过该商品!');
}else{
$data['m_id'] = I('post.m_id');
$data['g_id'] = I('post.g_id');
$data['ctime'] = time();
if($data){
//商品关注量加一
$this->good_obj->where(array('g_id'=>I('post.g_id')))->setInc('follow_volume');
$add_res = $follow_obj->addFollow($data);
if($add_res){
apiResponse('success','关注成功!');
}else{
apiResponse('error','关注失败!');
}
}
}
}