package com.vci.ubcs.ddl.mapper;
|
|
import com.vci.ubcs.ddl.bo.DdlTableBO;
|
import com.vci.ubcs.ddl.bo.DdlTableInDataBaseBO;
|
import org.apache.ibatis.annotations.*;
|
import org.springframework.stereotype.Repository;
|
|
import java.util.List;
|
|
/**
|
* Description: SqlServer数据库操作类
|
*
|
* @author LiHang
|
* @date 2023/4/24
|
*/
|
@Repository
|
public interface DdlMSMapper extends DdlMapper{
|
|
/**
|
* 向数据库表中添加单个字段
|
* @param tableName 表格的名称
|
* @param attributeSql 要添加的新的sql
|
* @return 影响的行数
|
*/
|
@Update("alter table ${tableName} add ${attributeSql} ")
|
@ResultType(Integer.class)
|
@Override
|
int addColumn2TableBySql(@Param("tableName") String tableName, @Param("attributeSql") String attributeSql);
|
|
/**
|
* 单个修改数据表的字段
|
* @param tableName 表格的名称
|
* @param attributeSql 属性新的sql
|
* @return 影响的行数
|
*/
|
@Update("alter table ${tableName} ALTER COLUMN ${attributeSql} ")
|
@ResultType(Integer.class)
|
@Override
|
int modifyTableBySql(@Param("tableName") String tableName, @Param("attributeSql") String attributeSql);
|
|
/**
|
* 删除表格
|
* @param tableName 表格名称
|
* @return 影响的行数
|
*/
|
@Update("drop table if exists ${tableName}")
|
@ResultType(Integer.class)
|
@Override
|
int dropTable(@Param("tableName") String tableName);
|
|
/**
|
* 校验数据库表或者视图是否存在--ms sql
|
* @param tableName 表格名称
|
* @return 存在的个数
|
*/
|
@Select("select count(name) from sysobjects where type in ('U','V') and upper(name) = upper(#{tableName,jdbcType=VARCHAR})")
|
@ResultType(Integer.class)
|
@Override
|
int checkTableExist(@Param("tableName") String tableName);
|
|
/**
|
* 查询表格的字段信息--sql server
|
* @param tableName 表格的名称
|
* @return 数据库表的字段信息
|
*/
|
List<DdlTableInDataBaseBO> selectTableColumnInfo(@Param("tableName") String tableName);
|
|
/**
|
* 删除表格中的列
|
* @param tableName 表名称
|
* @param columnName 列名称
|
* @return 受影响的行数
|
*/
|
@Override
|
int dropTableColumn(@Param("tableName")String tableName, @Param("columnName")String columnName);
|
|
|
/**
|
* 获取所有的表格名称
|
* @return 表格名称
|
*/
|
@Select("select name from sysobjects where type in ('U','V')")
|
List<String> selectAllTableName();
|
|
/**
|
* 查询表格的中文名称
|
* @param tableName 表格名称
|
* @return 表格名称和表格中文名称
|
*/
|
DdlTableBO selectTableComment(@Param("tableName")String tableName);
|
|
|
/**
|
* 创建数据库表
|
* @param tableName 表格的名称
|
* @param attributeSql 属性的sql
|
* @return 影响的行数
|
*/
|
@Update("create table ${tableName} ( ${attributeSql} )")
|
@ResultType(Integer.class)
|
@Override
|
int createTableBySql(@Param("tableName") String tableName, @Param("attributeSql") String attributeSql);
|
|
/**
|
* 为表格添加注释内容
|
* @param tableName 表格的名称
|
* @param comment 注释的内容
|
* @return 受影响的行数
|
*/
|
@Update("COMMENT ON TABLE ${tableName} IS '${comment}' ")
|
@ResultType(Integer.class)
|
@Override
|
int commentTable(@Param("tableName") String tableName, @Param("comment") String comment);
|
|
/**
|
* 为表格的列添加注释内容
|
* @param tableName 表格的名称
|
* @param columnName 列
|
* @param comment 注释的内容
|
* @return 受影响的行数
|
*/
|
@Update("COMMENT ON column ${tableName}.${columnName} IS '${comment}' ")
|
@ResultType(Integer.class)
|
@Override
|
int commentColumnTable(@Param("tableName") String tableName,@Param("columnName")String columnName, @Param("comment") String comment);
|
}
|