/* * ******************************************************************************************************************** * * iFHS7. * ;BBMBMBMc rZMBMBR BMB * MBEr:;PBM, 7MBMMEOBB: BBB RBW * XK: BO SB. :SZ MBM. c;; ir BBM :FFr :SSF: ;xBMB:r iuGXv. i:. iF2; * DBBM0r. :D S7 ;XMBMB GMBMu. MBM: BMB MBMBBBMBMS WMBMBMBBK MBMBMBM BMBRBMBW .MBMBMBMBB * :JMRMMD .. , 1MMRM1; ;MBMBBR: MBM ;MB: BMB: MBM. RMBr sBMH BM0 UMB, BMB. KMBv * ;. XOW B1; :uM: 1RE, i .2BMBs rMB. MBO MBO JMB; MBB MBM BBS 7MBMBOBM: MBW :BMc * OBRJ.SEE MRDOWOR, 3DE:7OBM . ;BMB RMR7BM BMB MBB. BMB ,BMR .BBZ MMB rMB, BMM rMB7 * :FBRO0D0 RKXSXPR. JOKOOMPi BMBSSWBMB; BMBB: MBMB0ZMBMS .BMBOXRBMB MBMDE RBM2;SMBM; MBB xBM2 * iZGE O0SHSPO. uGZ7. sBMBMBDL :BMO OZu:BMBK, rRBMB0; ,EBMB xBMBr:ER. RDU :OO; * ,BZ, 1D0 RPSFHXR. xWZ .SMr . .BBB * :0BMRDG RESSSKR. 2WOMBW; BMBMR * i0BM: SWKHKGO MBDv * .UB OOGDM. MK, Copyright (c) 2015-2020. 斯伯坦机器人 * , XMW .. * r All rights reserved. * * ******************************************************************************************************************** */ package com.sybotan.service.postgresql.controllers import com.sybotan.service.SObjectService import com.sybotan.service.models.requests.SQueryRequest import com.sybotan.service.models.responses.SQueryResponse import com.sybotan.service.postgresql.models.SColumn import com.sybotan.service.postgresql.models.STable import io.swagger.annotations.Api import io.swagger.annotations.ApiImplicitParam import io.swagger.annotations.ApiOperation import org.springframework.beans.factory.annotation.Autowired import org.springframework.web.bind.annotation.* /** * 数据库设计接口 * * @author 庞利祥(sybotan@126.com) */ @Api(tags= ["数据库设计接口"]) @RestController @RequestMapping("/--database-doc--/") class SDatabaseDocController { /** 表服务对象 */ private val tableService = SObjectService(STable::class.java) /** 字段服务对象 */ private val columnService = SObjectService(SColumn::class.java) /** * 查询表信息 * * @param schema 模式 * @return 字段列表 */ @ApiOperation(value="查询表信息", notes="") @RequestMapping(value = ["/table-list"], method = [RequestMethod.GET, RequestMethod.POST]) fun tableList(schema: String): List { return tableService.select("schemaName" to schema).exec() } // Function tableList() /** * 查询字段信息 * * @param schema 模式 * @param table 表名 * @return 字段列表 */ @ApiOperation(value="查询字段信息", notes="") @RequestMapping(value = ["/column-list"], method = [RequestMethod.GET, RequestMethod.POST]) fun columnList(schema: String, table: String): List { val builder = columnService.select("schemaName" to schema, "tableName" to table) builder.tableName = "(SELECT *,\n" + " (SELECT \"description\" FROM \"pg_description\"\n" + " JOIN \"pg_class\" ON \"pg_description\".\"objoid\" = \"pg_class\".\"oid\"\n" + " JOIN \"pg_namespace\" ON \"pg_class\".\"relnamespace\" = \"pg_namespace\".\"oid\"\n" + "WHERE \"relname\" = \"t\".\"table_name\" and \"nspname\"= \"t\".\"table_schema\" and \"objsubid\" = \"t\".\"ordinal_position\")\n" + "FROM \"information_schema\".\"columns\" t) ct" return builder.exec() //return mapper.columnList(schema, table) } // Function columnList() } // Class SDatabaseDocController