Imports System.Text
Imports UTS_Core.Database

Namespace UTSModule.DbTableModel.Manage
    ''' <summary>
    ''' 需要同步下载表名总表
    ''' </summary>
    Public Class SyncListTable
        Enum ColNamesEnum
            ID
            ''' <summary>
            ''' 表名
            ''' </summary>
            TableName
            ''' <summary>
            ''' 表版本编号
            ''' </summary>
            RevisionID
            ''' <summary>
            ''' 同步类型
            ''' </summary>
            SyncType
        End Enum

        Public Shared Property TableName() As String = "TBL_UTS_Manage_SyncList"

        
        ''' <summary>
        ''' 根据数据库类型,返回建表语句
        ''' </summary>
        ''' <param name="type">数据库类型</param>
        ''' <returns></returns>
        Public Shared Function CreateString(type As DbExecutor.DbTypeEnum) As String
            Dim createStr As New StringBuilder
            Select Case type
                Case DbExecutor.DbTypeEnum.Sqlite
                    createStr.Append($"Create Table If Not Exists {TableName}")
                    createStr.Append(" (")
                    createStr.Append($"{Customer.SyncListTable.ColNamesEnum.ID} INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL ,")
                    createStr.Append($"{Customer.SyncListTable.ColNamesEnum.TableName} varchar(254) NOT NULL ,")
                    createStr.Append($"{Customer.SyncListTable.ColNamesEnum.RevisionID} integer NOT NULL ,")
                    createStr.Append($"{Customer.SyncListTable.ColNamesEnum.SyncType} varchar(254)")
                    createStr.Append(" );")
                Case DbExecutor.DbTypeEnum.Mysql

                Case Else

            End Select

            Return createStr.ToString()
        End Function

    End Class
End Namespace