All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nbcp.myoql.db.sql.table.SqlBaseGroup.kt Maven / Gradle / Ivy

The newest version!
package nbcp.myoql.db.sql.table

import java.io.*
import nbcp.base.db.*
import nbcp.base.comm.*
import nbcp.base.extend.*
import nbcp.base.enums.*
import nbcp.base.utils.*
import nbcp.myoql.db.*
import nbcp.myoql.db.sql.*

import nbcp.myoql.db.comm.*
import nbcp.myoql.db.enums.*
import nbcp.myoql.db.sql.base.*
import nbcp.myoql.db.sql.enums.*
import nbcp.myoql.db.sql.define.*
import nbcp.myoql.db.sql.component.*
import org.springframework.stereotype.*



@Component("sql.SqlBase")
@MetaDataGroup(DatabaseEnum.SQL, "SqlBase")
class SqlBaseGroup : IDataGroup{
    override fun getEntities():Set> = setOf(s_annex,s_city,s_dustbin,s_flyway,s_log)

    val s_annex get() = s_annex_table();
    val s_city get() = s_city_table();
    val s_dustbin get() = s_dustbin_table();
    val s_flyway get() = s_flyway_table();
    val s_log get() = s_log_table();


    /**
     * 附件
     */
    @nbcp.base.db.annotation.DbEntityIndex(value = arrayOf("""id"""), unique = true )
    @nbcp.myoql.db.sql.annotation.ConverterValueToDb(value = nbcp.myoql.db.sql.define.AutoIdConverter::class, field = """id""")
    @nbcp.base.db.annotation.DbEntityGroup(value = """SqlBase""")
    @nbcp.base.db.annotation.Cn(value = """附件""")
    class s_annex_table(collectionName: String = "", datasource:String="")
        :SqlBaseMetaTable(nbcp.myoql.db.sql.entity.s_annex::class.java, "s_annex") {
        val name = SqlColumnName(DbType.STRING, this.getAliaTableName(),"name")
        val tags = SqlColumnName(DbType.JSON, this.getAliaTableName(),"tags")
        val ext = SqlColumnName(DbType.STRING, this.getAliaTableName(),"ext")
        val size = SqlColumnName(DbType.INT, this.getAliaTableName(),"size")
        val imgWidth = SqlColumnName(DbType.INT, this.getAliaTableName(),"imgWidth")
        val imgHeight = SqlColumnName(DbType.INT, this.getAliaTableName(),"imgHeight")
        val url = SqlColumnName(DbType.STRING, this.getAliaTableName(),"url")
        val creator_id = SqlColumnName(DbType.STRING, this.getAliaTableName(),"creator_id")
        val creator_name = SqlColumnName(DbType.STRING, this.getAliaTableName(),"creator_name")
        val group = SqlColumnName(DbType.STRING, this.getAliaTableName(),"group")
        val corpId = SqlColumnName(DbType.STRING, this.getAliaTableName(),"corpId")
        val errorMsg = SqlColumnName(DbType.STRING, this.getAliaTableName(),"errorMsg")
        val id = SqlColumnName(DbType.STRING, this.getAliaTableName(),"id")
        val createAt = SqlColumnName(DbType.DATE_TIME, this.getAliaTableName(),"createAt")
        val updateAt = SqlColumnName(DbType.DATE_TIME, this.getAliaTableName(),"updateAt")

        override fun getSpreadColumns(): Array { return arrayOf(SqlSpreadColumnData("creator","_"))}

        override fun getAutoIncrementKey(): String { return ""}
        override fun getUks(): Array>{ return arrayOf( arrayOf("id")  )}
        override fun getFks(): Array{ return arrayOf()}


        fun queryById (id: String): SqlQueryClip {
            return this.query().where{ it.id sqlEquals id }
        }

        fun deleteById (id: String): SqlDeleteClip {
            return this.delete().where{ it.id sqlEquals id }
        }

        fun updateById (id: String): SqlUpdateClip {
            return this.update().where{ it.id sqlEquals id }
        }

    }
    /**
     * 城市
     */
    @nbcp.base.db.annotation.DbEntityGroup(value = """SqlBase""")
    @nbcp.base.db.annotation.DbEntityIndex(value = arrayOf("""code"""), unique = true )
    @nbcp.base.db.annotation.Cn(value = """城市""")
    class s_city_table(collectionName: String = "", datasource:String="")
        :SqlBaseMetaTable(nbcp.myoql.db.sql.entity.s_city::class.java, "s_city") {
        val code = SqlColumnName(DbType.INT, this.getAliaTableName(),"code")
        val shortName = SqlColumnName(DbType.STRING, this.getAliaTableName(),"shortName")
        val name = SqlColumnName(DbType.STRING, this.getAliaTableName(),"name")
        val level = SqlColumnName(DbType.INT, this.getAliaTableName(),"level")
        val lng = SqlColumnName(DbType.FLOAT, this.getAliaTableName(),"lng")
        val lat = SqlColumnName(DbType.FLOAT, this.getAliaTableName(),"lat")
        val pinyin = SqlColumnName(DbType.STRING, this.getAliaTableName(),"pinyin")
        val telCode = SqlColumnName(DbType.STRING, this.getAliaTableName(),"telCode")
        val postCode = SqlColumnName(DbType.STRING, this.getAliaTableName(),"postCode")
        val pcode = SqlColumnName(DbType.INT, this.getAliaTableName(),"pcode")

        override fun getSpreadColumns(): Array { return arrayOf()}

        override fun getAutoIncrementKey(): String { return ""}
        override fun getUks(): Array>{ return arrayOf( arrayOf("code")  )}
        override fun getFks(): Array{ return arrayOf()}


        fun queryByCode (code: Int): SqlQueryClip {
            return this.query().where{ it.code sqlEquals code }
        }

        fun deleteByCode (code: Int): SqlDeleteClip {
            return this.delete().where{ it.code sqlEquals code }
        }

        fun updateByCode (code: Int): SqlUpdateClip {
            return this.update().where{ it.code sqlEquals code }
        }

    }
    /**
     * 数据垃圾箱
     */
    @nbcp.base.db.annotation.DbEntityIndex(value = arrayOf("""id"""), unique = true )
    @nbcp.myoql.db.sql.annotation.ConverterValueToDb(value = nbcp.myoql.db.sql.define.AutoIdConverter::class, field = """id""")
    @nbcp.base.db.annotation.DbEntityGroup(value = """SqlBase""")
    @nbcp.base.db.annotation.Cn(value = """数据垃圾箱""")
    class s_dustbin_table(collectionName: String = "", datasource:String="")
        :SqlBaseMetaTable(nbcp.myoql.db.sql.entity.s_dustbin::class.java, "s_dustbin") {
        val table = SqlColumnName(DbType.STRING, this.getAliaTableName(),"table")
        val remark = SqlColumnName(DbType.STRING, this.getAliaTableName(),"remark")
        val creator_id = SqlColumnName(DbType.STRING, this.getAliaTableName(),"creator_id")
        val creator_name = SqlColumnName(DbType.STRING, this.getAliaTableName(),"creator_name")
        val data = SqlColumnName(DbType.STRING, this.getAliaTableName(),"data")
        val id = SqlColumnName(DbType.STRING, this.getAliaTableName(),"id")
        val createAt = SqlColumnName(DbType.DATE_TIME, this.getAliaTableName(),"createAt")
        val updateAt = SqlColumnName(DbType.DATE_TIME, this.getAliaTableName(),"updateAt")

        override fun getSpreadColumns(): Array { return arrayOf(SqlSpreadColumnData("creator","_"))}

        override fun getAutoIncrementKey(): String { return ""}
        override fun getUks(): Array>{ return arrayOf( arrayOf("id")  )}
        override fun getFks(): Array{ return arrayOf()}


        fun queryById (id: String): SqlQueryClip {
            return this.query().where{ it.id sqlEquals id }
        }

        fun deleteById (id: String): SqlDeleteClip {
            return this.delete().where{ it.id sqlEquals id }
        }

        fun updateById (id: String): SqlUpdateClip {
            return this.update().where{ it.id sqlEquals id }
        }

    }
    /**
     * 数据版本初始化
     */
    @nbcp.base.db.annotation.DbEntityIndex(value = arrayOf("""id"""), unique = true)
    @nbcp.myoql.db.sql.annotation.ConverterValueToDb(value = nbcp.myoql.db.sql.define.AutoIdConverter::class, field = """id""")
    @nbcp.base.db.annotation.DbEntityGroup(value = """SqlBase""")
    @nbcp.base.db.annotation.Cn(value = """数据版本初始化""")
    class s_flyway_table(collectionName: String = "", datasource:String="")
        :SqlBaseMetaTable(nbcp.myoql.db.sql.entity.s_flyway::class.java, "s_flyway") {
        val version = SqlColumnName(DbType.INT, this.getAliaTableName(),"version")
        val remark = SqlColumnName(DbType.STRING, this.getAliaTableName(),"remark")
        val execClass = SqlColumnName(DbType.STRING, this.getAliaTableName(),"execClass")
        val startAt = SqlColumnName(DbType.DATE_TIME, this.getAliaTableName(),"startAt")
        val finishAt = SqlColumnName(DbType.DATE_TIME, this.getAliaTableName(),"finishAt")
        val isSuccess = SqlColumnName(DbType.BOOLEAN, this.getAliaTableName(),"isSuccess")
        val id = SqlColumnName(DbType.STRING, this.getAliaTableName(),"id")
        val createAt = SqlColumnName(DbType.DATE_TIME, this.getAliaTableName(),"createAt")
        val updateAt = SqlColumnName(DbType.DATE_TIME, this.getAliaTableName(),"updateAt")

        override fun getSpreadColumns(): Array { return arrayOf()}

        override fun getAutoIncrementKey(): String { return ""}
        override fun getUks(): Array>{ return arrayOf( arrayOf("id")  )}
        override fun getFks(): Array{ return arrayOf()}


        fun queryById (id: String): SqlQueryClip {
            return this.query().where{ it.id sqlEquals id }
        }

        fun deleteById (id: String): SqlDeleteClip {
            return this.delete().where{ it.id sqlEquals id }
        }

        fun updateById (id: String): SqlUpdateClip {
            return this.update().where{ it.id sqlEquals id }
        }

    }
    /**
     * 日志
     */
    @nbcp.base.db.annotation.DbEntityIndex(value = arrayOf("""id"""), unique = true)
    @nbcp.myoql.db.sql.annotation.ConverterValueToDb(value = nbcp.myoql.db.sql.define.AutoIdConverter::class, field = """id""")
    @nbcp.base.db.annotation.DbEntityGroup(value = """SqlBase""")
    @nbcp.base.db.annotation.Cn(value = """日志""")
    class s_log_table(collectionName: String = "", datasource:String="")
        :SqlBaseMetaTable(nbcp.myoql.db.sql.entity.s_log::class.java, "s_log") {
        val module = SqlColumnName(DbType.STRING, this.getAliaTableName(),"module")
        val type = SqlColumnName(DbType.STRING, this.getAliaTableName(),"type")
        val tags = SqlColumnName(DbType.JSON, this.getAliaTableName(),"tags")
        val msg = SqlColumnName(DbType.STRING, this.getAliaTableName(),"msg")
        val request = SqlColumnName(DbType.STRING, this.getAliaTableName(),"request")
        val data = SqlColumnName(DbType.STRING, this.getAliaTableName(),"data")
        val response = SqlColumnName(DbType.STRING, this.getAliaTableName(),"response")
        val creator_id = SqlColumnName(DbType.STRING, this.getAliaTableName(),"creator_id")
        val creator_name = SqlColumnName(DbType.STRING, this.getAliaTableName(),"creator_name")
        val id = SqlColumnName(DbType.STRING, this.getAliaTableName(),"id")
        val createAt = SqlColumnName(DbType.DATE_TIME, this.getAliaTableName(),"createAt")
        val updateAt = SqlColumnName(DbType.DATE_TIME, this.getAliaTableName(),"updateAt")

        override fun getSpreadColumns(): Array { return arrayOf(SqlSpreadColumnData("creator","_"))}

        override fun getAutoIncrementKey(): String { return ""}
        override fun getUks(): Array>{ return arrayOf( arrayOf("id")  )}
        override fun getFks(): Array{ return arrayOf()}


        fun queryById (id: String): SqlQueryClip {
            return this.query().where{ it.id sqlEquals id }
        }

        fun deleteById (id: String): SqlDeleteClip {
            return this.delete().where{ it.id sqlEquals id }
        }

        fun updateById (id: String): SqlUpdateClip {
            return this.update().where{ it.id sqlEquals id }
        }

    }
}

fun SqlUpdateClip.set_sAnnex_creator(creator:nbcp.base.db.IdName):SqlUpdateClip{
    return this.set{ it.creator_id to creator.id }
		.set{ it.creator_name to creator.name }
}


fun SqlUpdateClip.set_sDustbin_creator(creator:nbcp.base.db.IdName):SqlUpdateClip{
    return this.set{ it.creator_id to creator.id }
		.set{ it.creator_name to creator.name }
}


fun SqlUpdateClip.set_sLog_creator(creator:nbcp.base.db.IdName):SqlUpdateClip{
    return this.set{ it.creator_id to creator.id }
		.set{ it.creator_name to creator.name }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy