12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php namespace Api\Lib;
- use Dever;
- class App
- {
- public function update($db, $data)
- {
- $func = Dever::db('app_func_work', 'api')->select(array('app_func_id' => $data['id']));
- if ($func) {
- $platform = array();
- Dever::db('app_platform', 'api')->delete(array('app_id' => $data['app_id']));
- foreach ($func as $k => $v) {
- $api = Dever::db('api', 'api')->find($v['api_id']);
- if ($api) {
- $platform[$api['platform_id']] = $api['platform_id'];
- }
- }
- foreach ($platform as $k => $v) {
- Dever::db('app_platform', 'api')->insert(array('app_id' => $data['app_id'], 'platform_id' => $v));
- }
- }
- }
- public function updateApi($db, $data)
- {
- if (isset($data['notify']) && $data['notify'] == 2) {
- Dever::db('api/api_notify')->delete(array('api_id' => $data['id']));
- }
- }
- public function getPlatform($app)
- {
- $set['join'] = array
- (
- array
- (
- 'table' => 'platform',
- 'type' => 'left join',
- 'on' => 'platform.id=app_platform.platform_id',
- ),
- );
- $set['col'] = 'platform.id as id,platform.name as name';
- $platform = Dever::db('app_platform', 'api')->select(array('app_id' => $app), $set);
- return $platform;
- }
- public function getSetting($platform_id)
- {
- return Dever::db('platform_setting', 'api')->select(array('platform_id' => $platform_id));
- }
- public function getCert($platform_id)
- {
- return Dever::db('platform_cert', 'api')->select(array('platform_id' => $platform_id));
- }
- public function getCertName($id)
- {
- $info = Dever::db('platform_cert', 'api')->find($id);
- return $info['name'];
- }
- public function getApi($func_id, $env = 1)
- {
- $set['join'] = array
- (
- array
- (
- 'table' => 'api',
- 'type' => 'left join',
- 'on' => 'api.id=app_func_work.api_id',
- ),
- );
- $set['col'] = 'api.*';
- $set['order'] = 'app_func_work.sort asc,api.id desc';
- $where['app_func_work.app_func_id'] = $func_id;
- if ($env) {
- $where['api.env'] = $env;
- }
- return Dever::db('app_func_work', 'api')->select($where, $set);
- }
- public function getAppPlatform($app_id, $platform_id)
- {
- $app = Dever::db('app', 'api')->find($app_id);
- $platform = Dever::db('platform', 'api')->find($platform_id);
- return $app['name'] . '-' . $platform['name'];
- }
- }
|