1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
package com.vci.ubcs.ddl.service;
 
import com.vci.ubcs.ddl.bo.DdlTableBO;
import com.vci.ubcs.omd.dto.*;
import com.vci.ubcs.omd.entity.ModifyAttributeInfo;
import com.vci.ubcs.omd.vo.BtmTypeAttributeVO;
import com.vci.ubcs.omd.vo.BtmTypeVO;
import com.vci.ubcs.omd.vo.LinkTypeAttributeVO;
import com.vci.ubcs.omd.vo.LinkTypeVO;
import com.vci.ubcs.starter.exception.VciBaseException;
import org.springblade.core.tool.api.R;
 
import java.rmi.ServerException;
import java.util.Collection;
import java.util.List;
 
/**
 * Description: 数据库操作服务类
 *  注意的是,oracle对于DDL操作都会先提交一次事务,当执行完成后会再次提交一次事务
 *
 * @author LiHang
 * @date 2023/4/24
 */
public interface IDdlService {
    /**
     * 批量将业务类型创建数据库表
     * @param pkBtmTypes 业务类型的主键
     * @throws VciBaseException 参数为空或者创建表出现了错误的时候会抛出异常
     */
    void createDbTables(String pkBtmTypes) throws VciBaseException;
 
    /**
     * 批量将业务类型创建数据库表
     * @param oidCollection 业务类型的主键集合
     * @throws VciBaseException 参数为空或者创建表出现了错误的时候会抛出异常
     */
    void createDbTablesByOidCollection(Collection<String> oidCollection) throws VciBaseException;
 
    /**
     * 获取创建的sql语句中属性部分 -- 业务类型
     * @param attributeVOList 属性的立碑
     * @return sql语句
     */
    String getCreateSqlByAttributeForBtm(List<BtmTypeAttributeVO> attributeVOList);
 
    /**
     * 获取创建的sql语句中属性部分 -- 链接类型
     * @param attributeVOList 属性的立碑
     * @return sql语句
     */
    String getCreateSqlByAttributeForLink(List<LinkTypeAttributeVO> attributeVOList);
 
    /**
     * 批量将业务类型创建数据库表
     * @param ids 业务类型的英文名称
     * @throws VciBaseException 参数为空或者创建表出现了错误的时候会抛出异常
     */
    void createDbTablesById(String ids) throws VciBaseException;
 
    /**
     * 修改业务类型中的属性字段的长度,注意在执行这个方法时就会将以前的事务提交。
     * @param modifyLengthAttrDOList 需要修改的属性对象
     * @throws VciBaseException 执行出错的时候会抛出异常
     */
    void changeColumnForBtm(List<BtmTypeAttributeVO> modifyLengthAttrDOList) throws VciBaseException;
 
    /**
     * 修改链接类型中的属性字段的长度,注意在执行这个方法时就会将以前的事务提交。
     * @param modifyLengthAttrDOListForLinkType 需要修改的属性对象
     * @throws VciBaseException 执行出错的时候会抛出异常
     */
    void changeColumnForLink(List<LinkTypeAttributeVO> modifyLengthAttrDOListForLinkType) throws VciBaseException;
 
    /**
     * 添加属性字段到业务类型中,注意在执行这个方法时就会将以前的事务提交。
     * @param addAttrDOList 需要添加的属性对象
     * @throws VciBaseException 执行出错的时候会抛出异常
     */
    void addColumn2TableForBtm(List<BtmTypeAttributeVO> addAttrDOList) throws VciBaseException;
 
    /**
     * 添加属性字段到链接类型中,注意在执行这个方法时就会将以前的事务提交。
     * @param addAttrDOListForLinkType 需要添加的属性对象
     * @throws VciBaseException 执行出错的时候会抛出异常
     */
    void addColumn2TableForLink(List<LinkTypeAttributeVO> addAttrDOListForLinkType) throws VciBaseException;
 
    /**
     * 判断表中是否有数据
     * @param tableName 表格的名称
     * @return true表示有数据,false表示没有数据,或者这个表格不存在的时候抛出异常
     * @throws VciBaseException 参数错误的时候抛出异常
     */
    boolean checkTableHasDataByTableName(String tableName)  throws VciBaseException;
 
    /**
     * 创建视图
     * @param viewCreateSql 视图的SQL语句
     * @throws VciBaseException 参数错误或者执行错误的时候会抛出异常,执行错误主要包括SQL语句错误,没有权限等
     */
    void createViewBySql(String viewCreateSql) throws VciBaseException;
 
    /**
     * 删除表格或者视图
     * @param tableName 表格名称或者视图名称
     * @throws VciBaseException 参数错误或者执行错误的时候会抛出异常
     */
    void dropTableByName(String tableName) throws VciBaseException;
    /**
     * 删除表格的某一列
     * @param tableName 表格名称
     * @param columnName 列的名称
     */
    void dropColumnByName(String tableName, String columnName);
 
 
    /**
     * 根据表格的名称判断表格是否存在
     * @param tableName 表格名称
     * @return  rue表示存在,false表示不存在
     */
    boolean checkTableExistByTableName(String tableName);
 
 
    /**
     * 获取数据库和业务类型中的不同的地方
     * @param btmTypeVOList 业务类型对象,有属性时需要包含属性
     * @param linkTypeVOList 链接类型对象,有属性时需要包含属性
     * @return 不同的地方,每一个业务类型或者链接类型一条数据
     */
    List<ModifyAttributeInfo> checkDifferent(List<BtmTypeVO> btmTypeVOList, List<LinkTypeVO> linkTypeVOList) throws VciBaseException;
 
    /**
     * 清理业务类型中和数据库里不一样的
     * @param differentAttributeList 不同的属性的列表
     * @param btmTypeVOList 业务类型数据
     * @param linkTypeVOList 链接类型数据
     * @throws VciBaseException 参数为空或者执行出错的时候会抛出异常
     */
    void reflexDifferent(List<ModifyAttributeInfo> differentAttributeList,List<BtmTypeVO> btmTypeVOList, List<LinkTypeVO> linkTypeVOList) throws VciBaseException;
 
    /**
     * 获取数据库中所有的表格
     * @return 表格的名称,全是大写
     */
    List<String> listAllTableName() ;
 
    /**
     * 查询数据库中的表格信息
     * @param tableNamesCollections 数据库表名集合
     * @return 在数据库中的信息
     * @throws VciBaseException 参数为空或者数据库表不存在的时候会抛出异常
     */
    List<DdlTableBO> listTableInfoInDB(Collection<String> tableNamesCollections) throws VciBaseException;
 
    /**
     * 导出数据库中的表格信息到excel文件
     * @param tableNamesCollections 表格名称的集合
     * @param merge 合并表格名称
     * @return excel的文件名称
     * @throws VciBaseException 蚕食为空或者数据库表不存在的时候会抛出异常
     */
    String exportDataBase2File(Collection<String> tableNamesCollections,boolean merge) throws VciBaseException;
 
    /**
     * 获取存储文件所需要的临时文件夹,文件夹上已经包含了
     * @return 文件夹的地址,如果配置文件没有配置,则默认返回当前项目所在的文件夹
     */
    String getTempFolder();
 
    /**
     * 导出数据库中的表格信息到word文件中
     * @param tableNamesCollections 表格名称的集合
     * @return word的文件名称
     * @throws VciBaseException 蚕食为空或者数据库表不存在的时候会抛出异常
     */
    String exportDataBase2Word(List<String> tableNamesCollections) throws VciBaseException;
 
    /**
     * 拷贝数据到word模板中
     * @param tableDataBO 要写入的数据
     * @return word 文件路径
     *//*
    String writeDataToWord(WordMergeStartTableDataBO tableDataBO);*/
 
    /**
     * 判断是否为兼容性的表,这些表不应该被创建和修改
     * @param btmTypeId 业务类型的英文名称
     * @param linkTypeId 业务类型的中文名称
     * @return true 表示为兼容性的表,用户,角色,部门,权限这些
     */
    boolean isCompatibilityTable(String btmTypeId,String linkTypeId);
 
    /**
     * 数据库新增或修改表
     * @param ddlDTO 业务类型传输对象
     * @return 执行结果
     */
    R submit(BtmAndLinkTypeDdlDTO ddlDTO) throws ServerException;
 
    /**
     * 按表名获取表信息
     * @param tableName 表名
     * @return 表信息
     */
    DdlTableBO getTableColumnByTableName(String tableName);
 
    /**
     * 获取所有表信息
     * @return 表信息集合
     */
    List<BtmTypeVO> getAllTableInfo();
 
    /**
     * 检查数据表是否存在数据,不存在则删除
     * @param tableCheckDTOList 需要检查的表集合
     * @return 检查结果
     */
    TableCheckResultDTO checkTableHasDataThenDelete(List<TableCheckDTO> tableCheckDTOList);
 
    /**
     * 为表添加字段
     * @param addColumnDTO 添加的对象
     * @return 执行结果标识
     */
    Boolean addColumnForTable(TableAddColumnDTO addColumnDTO);
}