SDatabaseDocController.kt 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * ********************************************************************************************************************
  3. *
  4. * iFHS7.
  5. * ;BBMBMBMc rZMBMBR BMB
  6. * MBEr:;PBM, 7MBMMEOBB: BBB RBW
  7. * XK: BO SB. :SZ MBM. c;; ir BBM :FFr :SSF: ;xBMB:r iuGXv. i:. iF2;
  8. * DBBM0r. :D S7 ;XMBMB GMBMu. MBM: BMB MBMBBBMBMS WMBMBMBBK MBMBMBM BMBRBMBW .MBMBMBMBB
  9. * :JMRMMD .. , 1MMRM1; ;MBMBBR: MBM ;MB: BMB: MBM. RMBr sBMH BM0 UMB, BMB. KMBv
  10. * ;. XOW B1; :uM: 1RE, i .2BMBs rMB. MBO MBO JMB; MBB MBM BBS 7MBMBOBM: MBW :BMc
  11. * OBRJ.SEE MRDOWOR, 3DE:7OBM . ;BMB RMR7BM BMB MBB. BMB ,BMR .BBZ MMB rMB, BMM rMB7
  12. * :FBRO0D0 RKXSXPR. JOKOOMPi BMBSSWBMB; BMBB: MBMB0ZMBMS .BMBOXRBMB MBMDE RBM2;SMBM; MBB xBM2
  13. * iZGE O0SHSPO. uGZ7. sBMBMBDL :BMO OZu:BMBK, rRBMB0; ,EBMB xBMBr:ER. RDU :OO;
  14. * ,BZ, 1D0 RPSFHXR. xWZ .SMr . .BBB
  15. * :0BMRDG RESSSKR. 2WOMBW; BMBMR
  16. * i0BM: SWKHKGO MBDv
  17. * .UB OOGDM. MK, Copyright (c) 2015-2020. 斯伯坦机器人
  18. * , XMW ..
  19. * r All rights reserved.
  20. *
  21. * ********************************************************************************************************************
  22. */
  23. package com.sybotan.service.postgresql.controllers
  24. import com.sybotan.service.SObjectService
  25. import com.sybotan.service.models.requests.SQueryRequest
  26. import com.sybotan.service.models.responses.SQueryResponse
  27. import com.sybotan.service.postgresql.models.SColumn
  28. import com.sybotan.service.postgresql.models.STable
  29. import io.swagger.annotations.Api
  30. import io.swagger.annotations.ApiImplicitParam
  31. import io.swagger.annotations.ApiOperation
  32. import org.springframework.beans.factory.annotation.Autowired
  33. import org.springframework.web.bind.annotation.*
  34. /**
  35. * 数据库设计接口
  36. *
  37. * @author 庞利祥(sybotan@126.com)
  38. */
  39. @Api(tags= ["数据库设计接口"])
  40. @RestController
  41. @RequestMapping("/--database-doc--/")
  42. class SDatabaseDocController {
  43. /** 表服务对象 */
  44. private val tableService = SObjectService(STable::class.java)
  45. /** 字段服务对象 */
  46. private val columnService = SObjectService(SColumn::class.java)
  47. /**
  48. * 查询表信息
  49. *
  50. * @param schema 模式
  51. * @return 字段列表
  52. */
  53. @ApiOperation(value="查询表信息", notes="")
  54. @RequestMapping(value = ["/table-list"], method = [RequestMethod.GET, RequestMethod.POST])
  55. fun tableList(schema: String): List<Any> {
  56. return tableService.select("schemaName" to schema).exec()
  57. } // Function tableList()
  58. /**
  59. * 查询字段信息
  60. *
  61. * @param schema 模式
  62. * @param table 表名
  63. * @return 字段列表
  64. */
  65. @ApiOperation(value="查询字段信息", notes="")
  66. @RequestMapping(value = ["/column-list"], method = [RequestMethod.GET, RequestMethod.POST])
  67. fun columnList(schema: String, table: String): List<Any> {
  68. val builder = columnService.select("schemaName" to schema, "tableName" to table)
  69. builder.tableName =
  70. "(SELECT *,\n" +
  71. " (SELECT \"description\" FROM \"pg_description\"\n" +
  72. " JOIN \"pg_class\" ON \"pg_description\".\"objoid\" = \"pg_class\".\"oid\"\n" +
  73. " JOIN \"pg_namespace\" ON \"pg_class\".\"relnamespace\" = \"pg_namespace\".\"oid\"\n" +
  74. "WHERE \"relname\" = \"t\".\"table_name\" and \"nspname\"= \"t\".\"table_schema\" and \"objsubid\" = \"t\".\"ordinal_position\")\n" +
  75. "FROM \"information_schema\".\"columns\" t) ct"
  76. return builder.exec()
  77. //return mapper.columnList(schema, table)
  78. } // Function columnList()
  79. } // Class SDatabaseDocController