Manage.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php namespace Api\Api;
  2. use Dever;
  3. use Manage\Lib\Auth;
  4. class Manage extends Auth
  5. {
  6. # 将sku中的key解析成前端可以读取的格式
  7. public function keyToField($key, $param = array())
  8. {
  9. $project = $param['project'] ?? 'api';
  10. if ($key != -1) {
  11. $result = array();
  12. $array = explode(',', $key);
  13. $result['key']['set'] = array();
  14. foreach ($array as $k => $v) {
  15. $value = Dever::db('spec_value', $project)->find($v);
  16. if ($value) {
  17. $spec = Dever::db('spec', $project)->find($value['spec_id']);
  18. $result['key']['set']['s_' . $spec['id']] = array($spec['name'], $value['value']);
  19. }
  20. }
  21. return $result;
  22. }
  23. }
  24. # 获取参数设置表的参数名
  25. public function getSettingName($value = false)
  26. {
  27. if ($value) {
  28. $info = Dever::db('platform_setting', 'api')->find($value);
  29. $result['key']['value'] = $info['key'];
  30. return $result;
  31. }
  32. }
  33. # 获取参数设置表的参数名
  34. public function getCertName($value = false)
  35. {
  36. if ($value) {
  37. $info = Dever::db('platform_cert', 'api')->find($value);
  38. $result['type']['value'] = $info['type'];
  39. return $result;
  40. }
  41. }
  42. # 根据平台获取接口
  43. public function getApi($value = false)
  44. {
  45. if ($value) {
  46. $where['platform_id'] = $value;
  47. $result['api_id']['value'] = '';
  48. $result['api_id']['option'] = Dever::db('api', 'api')->select($where);
  49. return $result;
  50. }
  51. }
  52. # 根据应用获取平台
  53. public function getAppPlatform()
  54. {
  55. return Dever::load('common', 'manage')->cascader(2, function($level, $parent) {
  56. if ($level == 1) {
  57. $data = Dever::db('app', 'api')->select([]);
  58. } elseif ($level == 2) {
  59. $data = Dever::load('app', 'api')->getPlatform($parent);
  60. }
  61. return $data;
  62. });
  63. }
  64. }