Commit f229d7fd authored by shajiaiming's avatar shajiaiming

应用添加

parent e9f78ac6
...@@ -12,18 +12,6 @@ class ExploreApp extends BaseActiveRecord ...@@ -12,18 +12,6 @@ class ExploreApp extends BaseActiveRecord
const STATUS_ON = 1; //激活 const STATUS_ON = 1; //激活
const STATUS_OFF = 0; //未激活 const STATUS_OFF = 0; //未激活
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => new Expression('NOW()')
]
];
}
public static function getDb() public static function getDb()
{ {
return Yii::$app->get('p_sources'); return Yii::$app->get('p_sources');
......
...@@ -140,7 +140,9 @@ class ExploreAppController extends BaseController ...@@ -140,7 +140,9 @@ class ExploreAppController extends BaseController
{ {
$msg = 'ok'; $msg = 'ok';
$code = 0; $code = 0;
$platform_id = Yii::$app->request->getPlatformId();; $data = null;
$platform_id = Yii::$app->request->getPlatformId();
if (Yii::$app->request->isGet) {
$category_id = Yii::$app->request->get('id', 0); $category_id = Yii::$app->request->get('id', 0);
$page = Yii::$app->request->get('page', 1); $page = Yii::$app->request->get('page', 1);
if (false == $platform_id || false == $category_id) { if (false == $platform_id || false == $category_id) {
...@@ -150,7 +152,7 @@ class ExploreAppController extends BaseController ...@@ -150,7 +152,7 @@ class ExploreAppController extends BaseController
goto doEnd; goto doEnd;
} }
$query = ExploreApp::find() $query = ExploreApp::find()
->select('id, name, icon, sort, status, created_at') ->select('id, name, icon, sort, status')
->where(['app_category_id' => $category_id]) ->where(['app_category_id' => $category_id])
->andWhere(['platform_id' => $platform_id]) ->andWhere(['platform_id' => $platform_id])
->asArray(); ->asArray();
...@@ -169,6 +171,35 @@ class ExploreAppController extends BaseController ...@@ -169,6 +171,35 @@ class ExploreAppController extends BaseController
'currentPage' => $page, 'currentPage' => $page,
] ]
]; ];
goto doEnd;
}
if (Yii::$app->request->isPost){
$model = new ExploreApp();
$model->setScenario(ExploreApp::SCENARIOS_CREATE);
$params = Yii::$app->request->post();
$params['platform_id'] = $platform_id;
$lang = [
'zh-CN',
'en-US',
'ja'
];
$name_arr = $params['name'];
$name = [];
foreach ($name_arr as $key => $val) {
$name[$lang[$key]] = $val;
}
unset($params['name']);
$params['name'] = $name;
if ($model->load($params, '') && $model->save()) {
goto doEnd;
}
$msg = $model->errors;
$code = -1;
goto doEnd;
}
doEnd : doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data]; return ['code' => $code, 'msg' => $msg, 'data' => $data];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment