|
|
|
@ -9,8 +9,7 @@ import com.jfinal.plugin.activerecord.Page;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
import com.jfinal.plugin.activerecord.SqlPara;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
public class DataShareModel {
|
|
|
|
|
public Page<Record> listSystem(String keyword, int exclude, int page, int limit) {
|
|
|
|
@ -66,10 +65,16 @@ public class DataShareModel {
|
|
|
|
|
PgUtil.delUser(user_name);
|
|
|
|
|
//2、删除数据表记录
|
|
|
|
|
Db.deleteById("t_datashare_system", "system_id", system_id);
|
|
|
|
|
//3、删除此系统共享表
|
|
|
|
|
String sql = "delete from t_datashare_table where system_id=?";
|
|
|
|
|
|
|
|
|
|
//3、共享了哪些表
|
|
|
|
|
String sql = "select * from t_datashare_table where system_id=?";
|
|
|
|
|
List<Record> shareTableList = Db.find(sql, system_id);
|
|
|
|
|
//4、删除此系统共享表
|
|
|
|
|
sql = "delete from t_datashare_table where system_id=?";
|
|
|
|
|
Db.update(sql, system_id);
|
|
|
|
|
//4、删除所有其它系统对此系统的订阅
|
|
|
|
|
|
|
|
|
|
//5、删除所有其它系统对此系统的订阅
|
|
|
|
|
List<Integer> subSystemList = getSubSystemList(system_id);
|
|
|
|
|
sql = "select * from t_datashare_system";
|
|
|
|
|
List<Record> list = Db.find(sql);
|
|
|
|
|
for (Record record : list) {
|
|
|
|
@ -87,6 +92,37 @@ public class DataShareModel {
|
|
|
|
|
sql = "update t_datashare_system set subscribe_system_ids=? where system_id=?";
|
|
|
|
|
Db.update(sql, new_subscribe_system_ids, sub_system_id);
|
|
|
|
|
}
|
|
|
|
|
//5、回收其它订阅系统对它共享表的授权
|
|
|
|
|
for (Record record : shareTableList) {
|
|
|
|
|
String table_name = record.getStr("table_name");
|
|
|
|
|
for (Integer v_system_id : subSystemList) {
|
|
|
|
|
String v_user_name = getSystemById(v_system_id).getStr("user_name");
|
|
|
|
|
PgUtil.revokeUserPrivilege(v_user_name, table_name, PgUtil.READ);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:检查要共享的表是不是已经被其它业务系统共享过?
|
|
|
|
|
*
|
|
|
|
|
* @param table_names
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public boolean checkShareTable(int system_id, String table_names) {
|
|
|
|
|
String sql = "select * from t_datashare_table";
|
|
|
|
|
List<Record> list = Db.find(sql);
|
|
|
|
|
Map<String, Integer> _map = new HashMap<>();
|
|
|
|
|
for (Record record : list) {
|
|
|
|
|
_map.put(record.getStr("table_name"), record.getInt("system_id"));
|
|
|
|
|
}
|
|
|
|
|
for (String s : table_names.split(",")) {
|
|
|
|
|
if (_map.containsKey(s)) {
|
|
|
|
|
if (_map.get(s) != system_id) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|