作者 sgj
1 个管道 的构建 通过 耗费 1 秒

活动类型添加

... ... @@ -425,7 +425,30 @@ class IndexController extends RestBaseController
$this->success('',$pro);
}
/**
* @title 获取活动类型
* @title 通过城市获取活动
* @description 活动类型
* @author Xiaogang Wang
* @url /index/index/cityGetActivity
* @method GET
*
* @header name:XX-Token require:1 default: desc:token
*
* @param name:city_id type:int require:1 other: desc:城市id
* @return activity:活动@
* @activity id:id activity_name:活动名称 abstract:摘要 thumbnail:缩略图 time:时间 content:内容 province_name:省市地区
*/
public function cityGetActivity(){
$city_id=input('city_id');
$Activity=new ActivityModel();
$activity=$Activity->selectCityData($city_id);
$this->success('',$activity);
}
/**
* @title 获取活动类型列表
* @description 活动类型
* @author Xiaogang Wang
* @url /index/index/activityType
... ... @@ -442,5 +465,24 @@ class IndexController extends RestBaseController
$type=$Type->selectData();
$this->success('',$type);
}
/**
* @title 通过类型获取活动
* @description 活动类型
* @author Xiaogang Wang
* @url /index/index/typeGetActivity
* @method GET
*
* @header name:XX-Token require:1 default: desc:token
*
* @param name:city_id type:int require:1 other: desc:类型id
* @return activity:活动@
* @activity id:id activity_name:活动名称 abstract:摘要 thumbnail:缩略图 time:时间 content:内容 province_name:省市地区
*/
public function typeGetActivity(){
$type_id=input('type_id');
$Activity=new ActivityModel();
$activity=$Activity->selectTypeData($type_id);
$this->success('',$activity);
}
}
\ No newline at end of file
... ...
... ... @@ -56,6 +56,36 @@ class ActivityModel extends Model
->toArray();
return $data;
}
public function selectCityData($city_id){
$order = "create_time desc";
$where['a.delete_time'] = ['eq',0];
$where['a.position_id'] = $city_id;
$where['is_up'] = ['eq',1];
$data = $this->alias('a')
->field('a.*,p.province_name,act.type_name')
->join('activity_type act','act.id=a.activity_type','LEFT')
->join('position_province p','p.id=a.position_id','LEFT')
->where($where)
->order($order)
->select()
->toArray();
return $data;
}
public function selectTypeData($type_id){
$order = "create_time desc";
$where['a.delete_time'] = ['eq',0];
$where['a.activity_type'] = $type_id;
$where['is_up'] = ['eq',1];
$data = $this->alias('a')
->field('a.*,p.province_name,act.type_name')
->join('activity_type act','act.id=a.activity_type','LEFT')
->join('position_province p','p.id=a.position_id','LEFT')
->where($where)
->order($order)
->select()
->toArray();
return $data;
}
public function findData($where){
$data = $this->where($where)->find();
... ...