Commit f3e116f8 by wuchao

新版本

parent 8b29cad1
package com.chenyang.nse.bussiness.bean;
import com.chenyang.nse.bussiness.dao.table.core.TCoreDatasystemDao;
import com.chenyang.nse.bussiness.entity.orm.table.core.TCoreDatasystem;
import com.chenyang.nse.bussiness.odbc.DbCache;
import com.chenyang.nse.bussiness.service.core.impl.DataSystemServiceImpl;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
@Service
@EnableScheduling
public class DataCache {
@Autowired
TCoreDatasystemDao datasystemDao;
@Autowired
DataSystemServiceImpl dataSystemService;
private ExecutorService executorService = Executors.newFixedThreadPool(20);
public static List<DataBase> dataList = new CopyOnWriteArrayList();
@Scheduled(
cron = "0 0/20 * * * ?"
)
public void cacheData() throws InterruptedException {
List<TCoreDatasystem> dataSystemList = this.datasystemDao.queryAll();
for(int i = dataList.size() - 1; i >= 0; --i) {
DataBase dataBase = (DataBase)dataList.get(i);
boolean find = false;
for(TCoreDatasystem datasystem : dataSystemList) {
if (datasystem.getId().equals(dataBase.getDatasystemid())) {
find = true;
break;
}
}
if (!find) {
dataList.remove(dataBase);
}
}
CountDownLatch cdl = new CountDownLatch(dataSystemList.size());
for(TCoreDatasystem datasystem : dataSystemList) {
Runnable cacheThread = null;
Object var11;
if ("HIVE_TDH".equals(datasystem.getDbtype())) {
var11 = new CacheHiveTDH(this.dataSystemService, datasystem, cdl);
} else if ("MONGODB".equals(datasystem.getDbtype())) {
var11 = new CacheMongodb(this.dataSystemService, datasystem, cdl);
} else if ("ES".equals(datasystem.getDbtype())) {
var11 = new CacheElasticSearchThread(this.dataSystemService, datasystem, cdl);
} else {
var11 = new CacheThread(this.dataSystemService, datasystem, cdl);
}
this.executorService.execute((Runnable)var11);
}
cdl.await();
DbCache.sync();
}
}
package com.chenyang.nse.bussiness.controller.console;
import com.chenyang.nse.bussiness.entity.orm.table.console.mapping.TConsoleDatamappingTargetfield;
import com.chenyang.nse.bussiness.entity.vo.ComboboxVO;
import com.chenyang.nse.bussiness.enumeration.datamapping.EdataMappingFlag;
import com.chenyang.nse.bussiness.enumeration.datamapping.EdataMappingType;
import com.chenyang.nse.bussiness.service.console.DataMappingService;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping({"/console/datamapping"})
public class DataMappingController {
@Autowired
private DataMappingService dataMappingService;
@RequestMapping({"", "/"})
public String index(HttpServletRequest request, HttpServletResponse response, Model model) {
return "/console/datamapping";
}
@RequestMapping({"/getdatatype"})
@ResponseBody
public List<ComboboxVO> getdatatype() {
List<ComboboxVO> list = new ArrayList();
for(EdataMappingType em : EdataMappingType.values()) {
ComboboxVO vo = new ComboboxVO(em.getFlag(), em.getName());
list.add(vo);
}
return list;
}
@RequestMapping({"/getdataflag"})
@ResponseBody
public List<ComboboxVO> getdataflag() {
List<ComboboxVO> list = new ArrayList();
for(EdataMappingFlag em : EdataMappingFlag.values()) {
ComboboxVO vo = new ComboboxVO(em.getFlag(), em.getName());
list.add(vo);
}
return list;
}
@RequestMapping({"/getdatamappinginfo"})
@ResponseBody
public List<Map<String, String>> getdatamappinginfo(String sourcesystemtype, String targetsystemtype) {
return this.dataMappingService.getDatamappingInfo(sourcesystemtype, targetsystemtype);
}
@RequestMapping({"/gettargetfield"})
@ResponseBody
public List<ComboboxVO> gettargetfield(String datasystemtype) {
List<TConsoleDatamappingTargetfield> list = this.dataMappingService.getTargetFieldByType(datasystemtype);
List<ComboboxVO> volist = new ArrayList();
for(TConsoleDatamappingTargetfield item : list) {
ComboboxVO vo = new ComboboxVO(item.getId(), item.getFieldname());
volist.add(vo);
}
return volist;
}
@RequestMapping({"/modifydatainfo"})
@ResponseBody
public void modifydatainfo(@RequestParam Map<String, String> map) {
this.dataMappingService.modifyDataInfo(map);
}
}
package com.chenyang.nse.bussiness.controller.core;
import com.chenyang.nse.bussiness.commmon.json.RespHelper;
import com.chenyang.nse.bussiness.commmon.json.Response;
import com.chenyang.nse.bussiness.entity.orm.table.core.TCoreDatadis;
import com.chenyang.nse.bussiness.service.core.DataDisService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping({"/core/datadis"})
public class DataDisController {
@Autowired
private DataDisService dataDisService;
@ResponseBody
@GetMapping({"/queryAll"})
public Response query(String dbtype) {
List<TCoreDatadis> list = this.dataDisService.queryDistByType(dbtype);
return RespHelper.successResp(list);
}
}
package com.chenyang.nse.bussiness.controller.core;
import com.chenyang.nse.bussiness.commmon.json.RespHelper;
import com.chenyang.nse.bussiness.commmon.json.Response;
import com.chenyang.nse.bussiness.dao.PageInfo;
import com.chenyang.nse.bussiness.dao.table.core.TCoreDatasystemDao;
import com.chenyang.nse.bussiness.entity.orm.table.core.TCoreDataPreviewSQL;
import com.chenyang.nse.bussiness.entity.orm.table.core.TCoreDatasystem;
import com.chenyang.nse.bussiness.entity.vo.DataPreviewVO;
import com.chenyang.nse.bussiness.service.core.DataPreviewService;
import com.chenyang.nse.bussiness.tools.jdbc.MongodbTool;
import com.chenyang.nse.bussiness.tools.string.AesTool;
import com.chenyang.nse.bussiness.tools.string.StringTool;
import com.mongodb.MongoClient;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@EnableAsync
@Controller
@RequestMapping({"/core/datapreview"})
public class DataPreviewController {
private static Logger logger = LoggerFactory.getLogger(DataPreviewController.class);
@Autowired
private DataPreviewService dataPreviewService;
@Autowired
private TCoreDatasystemDao tCoreDatasystemDao;
@ResponseBody
@PostMapping({"/query"})
public Response<DataPreviewVO> queryPreviewBysql(@RequestBody DataPreviewVO dataPreviewVO) {
PageInfo pageInfo = new PageInfo();
pageInfo.setPageno(dataPreviewVO.getPage());
pageInfo.setPagesize(dataPreviewVO.getRows());
TCoreDatasystem tCoreDatasystem = (TCoreDatasystem)this.tCoreDatasystemDao.get(dataPreviewVO.getDatasystem_id());
if ("ES".equals(tCoreDatasystem.getDbtype())) {
long s = System.currentTimeMillis();
DataPreviewVO retDataPreviewVO = new DataPreviewVO();
String es = this.dataPreviewService.esQueryDataPreview(tCoreDatasystem, dataPreviewVO.getSql());
long e = System.currentTimeMillis();
retDataPreviewVO.setExecute_time(e - s);
TCoreDataPreviewSQL tcoreDataPreviewSQL = new TCoreDataPreviewSQL();
tcoreDataPreviewSQL.setExesql(dataPreviewVO.getSql());
tcoreDataPreviewSQL.setSchem(dataPreviewVO.getSchema());
tcoreDataPreviewSQL.setDatasystem_id(dataPreviewVO.getDatasystem_id());
tcoreDataPreviewSQL.setId(StringTool.getTablePrimaryKey());
tcoreDataPreviewSQL.setCreatetime(new Date());
String[] sqls = dataPreviewVO.getSql().split("/");
String table_name = sqls[2];
tcoreDataPreviewSQL.setTablename(table_name);
List<String> strings = new ArrayList();
strings.add(es);
retDataPreviewVO.setEsdata(strings);
return RespHelper.<DataPreviewVO>successResp(retDataPreviewVO);
} else if ("MONGODB".equals(tCoreDatasystem.getDbtype())) {
long s = System.currentTimeMillis();
DataPreviewVO retDataPreviewVO = new DataPreviewVO();
long e = System.currentTimeMillis();
retDataPreviewVO.setExecute_time(e - s);
String[] sqls = dataPreviewVO.getSql().split("\\.");
String table_name = sqls[1];
try {
MongoClient client = MongodbTool.connect(tCoreDatasystem.getDbservername(), tCoreDatasystem.getUsername(), AesTool.decrypt(tCoreDatasystem.getPassword(), "ghca"), tCoreDatasystem.getDbip(), Integer.parseInt(tCoreDatasystem.getDbport()), true);
List<String> strings = MongodbTool.findAllDataPreview(client, dataPreviewVO.getSchema(), table_name);
TCoreDataPreviewSQL tcoreDataPreviewSQL = new TCoreDataPreviewSQL();
tcoreDataPreviewSQL.setExesql(dataPreviewVO.getSql());
tcoreDataPreviewSQL.setSchem(dataPreviewVO.getSchema());
tcoreDataPreviewSQL.setDatasystem_id(dataPreviewVO.getDatasystem_id());
tcoreDataPreviewSQL.setId(StringTool.getTablePrimaryKey());
tcoreDataPreviewSQL.setCreatetime(new Date());
tcoreDataPreviewSQL.setTablename(table_name);
String ss = "";
for(int i = 0; i < strings.size(); ++i) {
if (i != 0) {
ss = ss + "," + (String)strings.get(i);
} else {
ss = ss + (String)strings.get(i);
}
}
retDataPreviewVO.setEsdata(strings);
} catch (Exception exception) {
exception.printStackTrace();
}
return RespHelper.<DataPreviewVO>successResp(retDataPreviewVO);
} else {
long s = System.currentTimeMillis();
String sql = dataPreviewVO.getSql();
if (!sql.trim().toLowerCase().startsWith("select")) {
return RespHelper.<DataPreviewVO>errRespStr("只支持查询功能语句!");
} else {
DataPreviewVO retDataPreviewVO = this.dataPreviewService.queryDataPreviewBysql(pageInfo, dataPreviewVO);
long e = System.currentTimeMillis();
retDataPreviewVO.setExecute_time(e - s);
retDataPreviewVO.setPageInfo(pageInfo);
return RespHelper.<DataPreviewVO>successResp(retDataPreviewVO);
}
}
}
@ResponseBody
@PostMapping({"/querySqlHistory"})
public Response<List<TCoreDataPreviewSQL>> querySqlHistory(@RequestBody TCoreDataPreviewSQL coreDataPreviewSQL) {
String datasystem_id = "";
if (!StringUtils.isBlank(coreDataPreviewSQL.getDatasystem_id())) {
datasystem_id = coreDataPreviewSQL.getDatasystem_id();
}
List<TCoreDataPreviewSQL> hisList = this.dataPreviewService.queryDataPreviewHis(datasystem_id);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
hisList.stream().limit(10L).forEach((hist) -> hist.setCreatetimeOfstr(sdf.format(hist.getCreatetime())));
return RespHelper.<List<TCoreDataPreviewSQL>>successResp(hisList);
}
}
package com.chenyang.nse.bussiness.controller.core;
import com.alibaba.fastjson.JSONObject;
import com.chenyang.nse.bussiness.commmon.json.ErrCode;
import com.chenyang.nse.bussiness.commmon.json.RespHelper;
import com.chenyang.nse.bussiness.commmon.json.Response;
import com.chenyang.nse.bussiness.config.PropertiesLoaderUtils;
import com.chenyang.nse.bussiness.dao.table.core.TCoreDataScopeDao;
import com.chenyang.nse.bussiness.entity.orm.table.core.DgDefineRule;
import com.chenyang.nse.bussiness.entity.orm.table.core.TCoreDataScope;
import com.chenyang.nse.bussiness.entity.orm.table.core.TCoreDatasystem;
import com.chenyang.nse.bussiness.entity.orm.table.core.dataproject.TCoreProjectVersion;
import com.chenyang.nse.bussiness.entity.orm.table.core.scopeproject.TProEditionScope;
import com.chenyang.nse.bussiness.entity.vo.datascope.DataScopeVO;
import com.chenyang.nse.bussiness.entity.vo.datascope.EditionProjectReqVO;
import com.chenyang.nse.bussiness.service.console.OperationService;
import com.chenyang.nse.bussiness.service.core.ComplianceDirectoryService;
import com.chenyang.nse.bussiness.service.core.DataScopeService;
import com.chenyang.nse.bussiness.service.core.DataSystemService;
import com.chenyang.nse.bussiness.service.core.SearchFieldService;
import com.chenyang.nse.bussiness.service.redis.RedisService;
import com.chenyang.nse.bussiness.tools.io.FileTool;
import com.chenyang.nse.bussiness.tools.login.CommonUtils;
import com.chenyang.nse.bussiness.tools.office.ExcelTool;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
@Controller
@RequestMapping({"/core/datascope"})
public class DataScopeController {
public static final String Excel_Model_Down = "datascope.xlsx";
@Autowired
private DataScopeService dataScopeService;
@Autowired
private ComplianceDirectoryService complianceDirectoryService;
@Autowired
private RedisService redisService;
@Autowired
private DataSystemService dataSystemService;
@Autowired
private SearchFieldService searchFieldService;
@Autowired
private OperationService operationService;
@Autowired
private TCoreDataScopeDao tCoreDataScopeDao;
@RequestMapping
public String index(HttpServletRequest request, HttpServletResponse response, Model model) {
String id = request.getParameter("id");
model.addAttribute("id", id);
return "core/datascope/datascopebase";
}
@ResponseBody
@RequestMapping({"/querydatasystem"})
public Response<List<TCoreDatasystem>> querydatasource(@RequestBody Map<String, String> map) {
String projectId = (String)map.get("projectId");
String userId = (String)map.get("userId");
List<TCoreDatasystem> list = new ArrayList();
list.addAll(this.dataSystemService.querydatasourceds(projectId, userId));
List<TCoreDatasystem> reList = new ArrayList();
for(int i = 0; i < list.size(); ++i) {
String icon = ((TCoreDatasystem)list.get(i)).getDbtype().toLowerCase();
((TCoreDatasystem)list.get(i)).setIconCls(icon);
if ("1".equals(((TCoreDatasystem)list.get(i)).getFlag())) {
reList.add(list.get(i));
}
}
return RespHelper.<List<TCoreDatasystem>>successResp(list);
}
@ResponseBody
@RequestMapping({"/getscopetable"})
public Response<List<DataScopeVO>> getScopeTable(@RequestBody DataScopeVO vo) {
List<DataScopeVO> table = this.dataScopeService.getScopeTable(vo.getEdition_id());
return RespHelper.<List<DataScopeVO>>successResp(table);
}
@ResponseBody
@RequestMapping({"/save"})
public Response<String> save(@RequestBody EditionProjectReqVO vo, HttpServletRequest request) {
DgDefineRule record = new DgDefineRule();
record.setModule("分类定义");
record.setFlag("1");
record.setOperationtime(new Date());
record.setOperationUser(vo.getLoginUser().getTsysUser().getUsername());
vo.getDataScopeVO().setCreate_user(vo.getLoginUser().getTsysUser().getUsername());
boolean isRepeat = false;
String id = vo.getDataScopeVO().getTid();
String fa_tid = vo.getDataScopeVO().getFa_tid() == null ? "全部" : vo.getDataScopeVO().getFa_tid();
for(TCoreDataScope edition : this.tCoreDataScopeDao.queryAll(new Criterion[]{Restrictions.eq("scope_name", vo.getDataScopeVO().getText()), Restrictions.eq("edition_id", vo.getDataScopeVO().getEdition_id()), Restrictions.eq("fa_tid", fa_tid)})) {
isRepeat = true;
if (id == null) {
return RespHelper.<String>errResp(ErrCode.DATA_IS_EXIST);
}
if (edition.getId().equals(id)) {
isRepeat = false;
break;
}
}
if (isRepeat) {
return RespHelper.<String>errResp(ErrCode.DATA_IS_EXIST);
} else {
this.dataScopeService.save(vo.getDataScopeVO());
if (vo.getDataScopeVO().getTid() == null) {
record.setLogmessage("新增分类定义");
} else {
record.setLogmessage("编辑分类定义");
}
this.operationService.addDefineLog(record);
return RespHelper.<String>successResp();
}
}
@ResponseBody
@RequestMapping({"/remove"})
public Response<String> remove(@RequestBody DataScopeVO vo) {
DgDefineRule record = new DgDefineRule();
record.setModule("分类定义");
record.setFlag("1");
record.setOperationtime(new Date());
record.setOperationUser(CommonUtils.loginUsername());
record.setLogmessage("删除分类定义");
this.dataScopeService.remove(vo.getTid());
this.operationService.addDefineLog(record);
return RespHelper.<String>successResp();
}
@ResponseBody
@RequestMapping({"/editbyid"})
public Response<DataScopeVO> editbyid(@RequestBody DataScopeVO vo) {
DataScopeVO data = this.dataScopeService.editbyid(vo.getTid());
return RespHelper.<DataScopeVO>successResp(data);
}
@ResponseBody
@RequestMapping({"/datacount"})
public String datacount(String id, HttpServletRequest request, HttpServletResponse response, Model model) {
this.dataScopeService.saveDataToRedis();
this.dataScopeService.getDataFromTable();
return "1";
}
@ResponseBody
@RequestMapping({"/getprocess"})
public String getprocess(String id, HttpServletRequest request, HttpServletResponse response, Model model) {
String process = (String)this.redisService.get("proess");
return process;
}
@ResponseBody
@RequestMapping({"/removeDataRedis"})
public String removeDataRedis(String id, HttpServletRequest request, HttpServletResponse response, Model model) {
this.dataScopeService.removeDataToRedis();
return "1";
}
@ResponseBody
@RequestMapping({"/geteditionlist"})
public Response<List<TProEditionScope>> geteditionlist(@RequestBody TCoreProjectVersion vo) {
List<TProEditionScope> list = this.dataScopeService.geteditionlistds(vo.getProjectid());
return RespHelper.<List<TProEditionScope>>successResp(list);
}
@ResponseBody
@RequestMapping({"/getmaxdatetid"})
public Response<String> getmaxdatetid(@RequestBody DataScopeVO vo) {
String id = this.dataScopeService.getmaxdatetid(vo.getEdition_id());
return RespHelper.<String>successResp(id);
}
@ResponseBody
@RequestMapping({"/excelmodeldown"})
public String excelModelDown(HttpServletRequest request, HttpServletResponse response, Model model) {
String userAgent = request.getHeader("User-Agent");
Properties props = new Properties();
try {
props = PropertiesLoaderUtils.loadAllProperties("config.properties");
} catch (IOException e) {
e.printStackTrace();
}
String path = props.getProperty("excelModelDown");
path = path + "/" + "datascope.xlsx";
try {
String name = "datascope.xlsx";
if (!userAgent.contains("MSIE") && !userAgent.contains("Trident")) {
name = new String("datascope.xlsx".getBytes("UTF-8"), "ISO-8859-1");
} else {
name = URLEncoder.encode("datascope.xlsx", "UTF-8");
}
response.setCharacterEncoding("utf-8");
response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition", "attachment;fileName=" + name);
InputStream inputStream = new FileInputStream(new File(path));
OutputStream os = response.getOutputStream();
byte[] b = new byte[2048];
int length;
while((length = inputStream.read(b)) > 0) {
os.write(b, 0, length);
}
os.close();
inputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@ResponseBody
@RequestMapping({"/excelmodelup"})
public Response<String> excelModelUp(@RequestParam("file") MultipartFile file, @RequestParam("editionid") String editionid, @RequestParam("userName") String userName) {
boolean flag = true;
String user = userName;
new Properties();
String filename = file.getOriginalFilename();
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Properties props = PropertiesLoaderUtils.loadAllProperties("config.properties");
String path = props.getProperty("excelModelDown");
if (!FileTool.isFileExit(path)) {
FileTool.createFolder(path);
}
File mappletfile = new File(path, filename);
mappletfile.createNewFile();
file.transferTo(mappletfile);
String filepath = path + "/" + filename;
List<List<String>> list = ExcelTool.readExcel(filepath, 0);
this.dataScopeService.removeByEdition(editionid);
this.dataScopeService.saveExcelData(list, editionid, user);
System.out.println(list);
FileTool.removeFile(filepath);
} catch (Exception e) {
flag = false;
e.printStackTrace();
}
return RespHelper.<String>successResp();
}
@ResponseBody
@RequestMapping({"/checkname"})
public String checkName(String scopename, String editionid) {
String check = this.dataScopeService.checkName(scopename, editionid);
return check;
}
public List<Object> getChildren(String Id, List<DataScopeVO> fileDirectories, List<String> fieldScopeIdList) {
List<Object> list = new ArrayList();
for(DataScopeVO f : fileDirectories) {
JSONObject obj = new JSONObject();
obj.put("id", f.getTid());
obj.put("title", f.getText());
obj.put("pid", Id);
obj.put("spread", true);
if (fieldScopeIdList.contains(f.getTid())) {
obj.put("checked", true);
}
if (f.getChildren() != null) {
obj.put("children", this.getChildren(f.getId(), f.getChildren(), fieldScopeIdList));
}
list.add(obj);
}
return list;
}
}
package com.chenyang.nse.bussiness.controller.core.backup;
import cn.hutool.core.util.ObjectUtil;
import com.chenyang.nse.bussiness.commmon.json.ErrCode;
import com.chenyang.nse.bussiness.commmon.json.RespHelper;
import com.chenyang.nse.bussiness.commmon.json.Response;
import com.chenyang.nse.bussiness.config.PropertiesLoaderUtils;
import com.chenyang.nse.bussiness.entity.vo.dataproject.TCoreDataBackUpVO;
import com.chenyang.nse.bussiness.service.core.backup.DataBackUpService;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
@Controller
@RequestMapping({"/core/backup"})
public class DataBackUpController {
@Autowired
DataBackUpService dataBackUpService;
@PostMapping({"/checkTable"})
@ResponseBody
public Response checkTable(@RequestBody TCoreDataBackUpVO params) {
String msg = this.dataBackUpService.checkTable(params);
if (msg != null) {
return RespHelper.createResp(ErrCode.DATA_IS_EXIST.getCode(), String.format("%s 已经存在.", msg));
} else {
HashMap<String, String> map = new HashMap();
map.put("msg", "1");
return RespHelper.successResp(map);
}
}
@RequestMapping({"/dataSync"})
@ResponseBody
public Response dataSync(@RequestBody TCoreDataBackUpVO params) {
this.dataBackUpService.dataSync(params);
return RespHelper.successResp();
}
@RequestMapping({"/exportSql"})
@ResponseBody
public void exportSql(HttpServletResponse response) {
Process process = null;
new Properties();
try {
Properties properties = PropertiesLoaderUtils.loadAllProperties("config.properties");
Runtime runtime = Runtime.getRuntime();
String command = getExportCommand(properties);
process = runtime.exec(command);
process.waitFor();
String filePath = properties.getProperty("jdbc.exportPath");
this.loadFile(filePath, response);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (process != null) {
process.destroy();
}
}
}
@RequestMapping({"/importSql"})
@ResponseBody
public Response importSql(HttpServletRequest request, HttpServletResponse response, @RequestParam("fileUpload") MultipartFile sqlFile) throws IOException {
new Properties();
InputStream in = null;
try {
Properties properties = PropertiesLoaderUtils.loadAllProperties("config.properties");
String msg = null;
if (ObjectUtil.isEmpty(sqlFile)) {
msg = "请添加文件";
Response var92 = RespHelper.successResp(msg);
return var92;
}
in = sqlFile.getInputStream();
String importPath = properties.getProperty("jdbc.importPath");
File importFile = new File(importPath);
if (!importFile.exists()) {
importFile.getParentFile().mkdirs();
try {
importFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
OutputStream fileOutputStreams = new FileOutputStream(importPath);
Throwable cmdarray = null;
try {
byte[] temp_info = new byte[1024];
int size = 0;
do {
size = in.read(temp_info);
if (size != -1) {
fileOutputStreams.write(temp_info, 0, size);
}
} while(size != -1);
} catch (Throwable var87) {
cmdarray = var87;
throw var87;
} finally {
if (fileOutputStreams != null) {
if (cmdarray != null) {
try {
fileOutputStreams.close();
} catch (Throwable var81) {
cmdarray.addSuppressed(var81);
}
} else {
fileOutputStreams.close();
}
}
}
Runtime runtime = Runtime.getRuntime();
String[] cmdarrayNew = getImportCommand(properties);
Process process = runtime.exec(cmdarrayNew[0]);
OutputStream os = process.getOutputStream();
Throwable var13 = null;
try {
OutputStreamWriter writer = new OutputStreamWriter(os);
Throwable var15 = null;
try {
writer.write(cmdarrayNew[1] + "\r\n" + cmdarrayNew[2]);
} catch (Throwable var82) {
var15 = var82;
throw var82;
} finally {
if (writer != null) {
if (var15 != null) {
try {
writer.close();
} catch (Throwable var80) {
var15.addSuppressed(var80);
}
} else {
writer.close();
}
}
}
} catch (Throwable var85) {
var13 = var85;
throw var85;
} finally {
if (os != null) {
if (var13 != null) {
try {
os.close();
} catch (Throwable var79) {
var13.addSuppressed(var79);
}
} else {
os.close();
}
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
in.close();
}
return RespHelper.successResp();
}
private static String[] getImportCommand(Properties properties) {
String username = properties.getProperty("jdbc.user");
String password = properties.getProperty("jdbc.password");
String host = properties.getProperty("jdbc.host");
String port = properties.getProperty("jdbc.port");
String importDatabaseName = properties.getProperty("jdbc.importDatabaseName");
String importPath = properties.getProperty("jdbc.importPath");
String MysqlPath = properties.getProperty("MysqlPath");
String loginCommand = MysqlPath + "mysql -h" + host + " -u" + username + " -p" + password + " -P" + port;
String switchCommand = "use " + importDatabaseName;
String importCommand = " source " + importPath;
String[] commands = new String[]{loginCommand, switchCommand, importCommand};
return commands;
}
private static String getExportCommand(Properties properties) {
StringBuilder command = new StringBuilder();
String username = properties.getProperty("jdbc.user");
String password = properties.getProperty("jdbc.password");
String exportDatabaseName = properties.getProperty("jdbc.exportDatabaseName");
String host = properties.getProperty("jdbc.host");
String port = properties.getProperty("jdbc.port");
String exportPath = properties.getProperty("jdbc.exportPath");
File sqlFile = new File(exportPath);
if (!sqlFile.exists()) {
sqlFile.getParentFile().mkdirs();
try {
sqlFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
String MysqlPath = properties.getProperty("MysqlPath");
command.append(MysqlPath).append("mysqldump -u").append(username).append(" -p").append(password).append(" -h").append(host).append(" -P").append(port).append(" ").append(exportDatabaseName).append(" -r ").append(exportPath);
return command.toString();
}
public void loadFile(String filePath, HttpServletResponse response) {
BufferedInputStream in = null;
BufferedOutputStream out = null;
try {
if (null == filePath) {
throw new Exception("invalid filepath of null");
}
File file = new File(filePath);
if (!file.exists()) {
throw new Exception("file not exist in path [" + filePath + "]");
}
String fileName = file.getName();
in = new BufferedInputStream(new FileInputStream(filePath));
out = new BufferedOutputStream(response.getOutputStream());
response.setContentType("application/x-download;charset=utf-8");
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
byte[] buffer = new byte[8192];
int count = 0;
while((count = in.read(buffer, 0, 8192)) != -1) {
out.write(buffer, 0, count);
}
out.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeStream(in, out);
}
}
public void closeStream(InputStream in, OutputStream out) {
if (null != in) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != out) {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void exportData(String name, HttpServletResponse response) throws Exception {
File sqlFile = new File(name);
response.setContentType("application/octet-stream");
response.setHeader("content-disposition", "attachment; filename=backup.sql");
response.setContentLengthLong(sqlFile.length());
FileInputStream fileInputStream = new FileInputStream(sqlFile);
Throwable var5 = null;
try {
StreamUtils.copy(fileInputStream, response.getOutputStream());
} catch (Throwable var14) {
var5 = var14;
throw var14;
} finally {
if (fileInputStream != null) {
if (var5 != null) {
try {
fileInputStream.close();
} catch (Throwable var13) {
var5.addSuppressed(var13);
}
} else {
fileInputStream.close();
}
}
}
}
}
package com.chenyang.nse.bussiness.controller.restfulapi;
import com.alibaba.fastjson.JSONObject;
import com.chenyang.nse.bussiness.controller.restfulapi.entity.ResultAPIEnum;
import com.chenyang.nse.bussiness.controller.restfulapi.tools.ApiTool;
import com.chenyang.nse.bussiness.controller.restfulapi.tools.AuthorizationTool;
import com.chenyang.nse.bussiness.engine.ghca.webservice.DesensitizationEngineInterfaceImpl;
import com.chenyang.nse.bussiness.engine.ghca.webservice.DesensitizationEngineInterfaceImplService;
import com.chenyang.nse.bussiness.entity.orm.table.core.api.ApiInfoLog;
import com.chenyang.nse.bussiness.service.core.api.ApiInfoLogService;
import com.chenyang.nse.bussiness.service.redis.RedisService;
import com.chenyang.nse.bussiness.tools.token.TokenUtil;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping({"/api/dg"})
public class DataMaskingAPIController {
@Autowired
private ApiInfoLogService apiInfoLogService;
@Autowired
private RedisService redisService;
@ResponseBody
@RequestMapping(
value = {"/re/{rulename}/dr/{dataVar}"},
method = {RequestMethod.POST},
produces = {"text/json;charset=UTF-8"}
)
public String postDataMasking(@PathVariable("rulename") String rulename, @PathVariable("dataVar") Object dataVar, HttpServletRequest request) {
label58: {
Map<String, Object> result = new HashMap();
result.put("code", ResultAPIEnum.RT_SUC_CODE_200_STR.getCode());
result.put("msg", ResultAPIEnum.RT_SUC_CODE_200_STR.getMsg());
String token = request.getHeader("token");
String cilentip = request.getRemoteAddr();
String reqUrl = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getRequestURI();
if (!TokenUtil.verify(token)) {
String reqUrlsubStr = reqUrl.substring(0, reqUrl.lastIndexOf("/dr"));
Map<String, String> rvMap = AuthorizationTool.releaseVerification(reqUrlsubStr, "3");
if ("0".equals(rvMap.get("code"))) {
try {
DesensitizationEngineInterfaceImplService engineInterfaceImplService = new DesensitizationEngineInterfaceImplService();
DesensitizationEngineInterfaceImpl engineInterfaceImpl = (DesensitizationEngineInterfaceImpl)engineInterfaceImplService.getPort(DesensitizationEngineInterfaceImpl.class);
List<Object> dataList = new ArrayList();
dataList.add(dataVar);
List<Object> reList = engineInterfaceImpl.dataMaskingListByRuleName(rulename, dataList);
if (null != reList && reList.size() != 0) {
List<Map<String, Object>> tdResultMapList = ApiTool.realObjectsToMaps(reList);
result.put("data", tdResultMapList);
}
result.put("code", ResultAPIEnum.RT_ERROR_CODE_403_STR.getCode());
result.put("msg", ResultAPIEnum.RT_ERROR_CODE_403_STR.getMsg());
} catch (Exception e) {
System.out.println(">>>>>>>>调用脱敏引擎dataMaskingListByRuleName方法出错..");
result.put("code", ResultAPIEnum.RT_ERROR_CODE_432_STR.getCode());
result.put("msg", ResultAPIEnum.RT_ERROR_CODE_432_STR.getMsg());
e.printStackTrace();
} finally {
String message = JSONObject.toJSONString(result);
ApiInfoLog info = new ApiInfoLog();
info.setApitype("3");
info.setAuthorization(token);
info.setUsername(TokenUtil.getUserId(token));
info.setCalldatetime(new Date());
info.setCreatetime(new Date());
info.setRestatus(String.valueOf(result.get("code")));
info.setRemsg(String.valueOf(result.get("msg")));
info.setUrl(reqUrl);
info.setCilentip(cilentip);
this.apiInfoLogService.save(info);
System.out.println(message);
return message;
}
}
result.put("code", ResultAPIEnum.RT_ERROR_CODE_431_STR.getCode());
result.put("msg", rvMap.get("msg"));
} else {
result.put("code", ResultAPIEnum.RT_ERROR_CODE_400_STR.getCode());
result.put("msg", "Invalid Request");
}
String message = JSONObject.toJSONString(result);
ApiInfoLog info = new ApiInfoLog();
info.setApitype("3");
info.setAuthorization(token);
info.setUsername(TokenUtil.getUserId(token));
info.setCalldatetime(new Date());
info.setCreatetime(new Date());
info.setRestatus(String.valueOf(result.get("code")));
info.setRemsg(String.valueOf(result.get("msg")));
info.setUrl(reqUrl);
info.setCilentip(cilentip);
this.apiInfoLogService.save(info);
System.out.println(message);
return message;
}
}
@ResponseBody
@RequestMapping(
value = {"/re/{rulename}/dr/{dataVar}/test"},
method = {RequestMethod.POST},
produces = {"text/json;charset=UTF-8"}
)
public String postDataMaskingTest(@PathVariable("rulename") String rulename, @PathVariable("dataVar") Object dataVar, HttpServletRequest request) {
Map<String, Object> result = new HashMap();
try {
dataVar = new String(dataVar.toString().getBytes("UTF-8"), "UTF-8");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
result.put("code", ResultAPIEnum.RT_SUC_CODE_200_STR.getCode());
result.put("msg", ResultAPIEnum.RT_SUC_CODE_200_STR.getMsg());
String token = request.getHeader("token");
if (TokenUtil.verify(token)) {
try {
DesensitizationEngineInterfaceImplService engineInterfaceImplService = new DesensitizationEngineInterfaceImplService();
DesensitizationEngineInterfaceImpl engineInterfaceImpl = (DesensitizationEngineInterfaceImpl)engineInterfaceImplService.getPort(DesensitizationEngineInterfaceImpl.class);
List<Object> dataList = new ArrayList();
dataList.add(dataVar);
List<Object> reList = engineInterfaceImpl.dataMaskingListByRuleName(rulename, dataList);
if (null != reList && reList.size() != 0) {
List<Map<String, Object>> tdResultMapList = ApiTool.realObjectsToMaps(reList);
result.put("data", tdResultMapList);
} else {
result.put("code", ResultAPIEnum.RT_ERROR_CODE_403_STR.getCode());
result.put("msg", ResultAPIEnum.RT_ERROR_CODE_403_STR.getMsg());
}
} catch (Exception e) {
System.out.println(">>>>>>>>调用脱敏引擎dataMaskingListByRuleName方法出错..");
result.put("code", ResultAPIEnum.RT_ERROR_CODE_432_STR.getCode());
result.put("msg", ResultAPIEnum.RT_ERROR_CODE_432_STR.getMsg());
e.printStackTrace();
}
} else {
result.put("code", ResultAPIEnum.RT_ERROR_CODE_400_STR.getCode());
result.put("msg", "Invalid Request");
}
String message = JSONObject.toJSONString(result);
System.out.println(message);
return message;
}
@ResponseBody
@RequestMapping(
value = {"/re/{rulename}/dr/{dataVar}"},
method = {RequestMethod.GET},
produces = {"text/json;charset=UTF-8"}
)
public String getDataMasking(@PathVariable("rulename") String rulename, @PathVariable("dataVar") Object dataVar, HttpServletRequest request, HttpServletResponse response) {
String token = request.getHeader("token");
String cilentip = request.getRemoteAddr();
String reqUrl = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getRequestURI();
if (!TokenUtil.verify(token)) {
response.setStatus(401);
response.setHeader("WWW-Authenticate", "Basic realm=\"My Application\"");
response.setContentType("text/html; charset=UTF-8");
try {
response.getWriter().print("HTTP STATUS -- 401!");
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
;
}
} else {
Map<String, Object> result = new HashMap();
result.put("code", ResultAPIEnum.RT_SUC_CODE_200_STR.getCode());
result.put("msg", ResultAPIEnum.RT_SUC_CODE_200_STR.getMsg());
String reqUrlsubStr = reqUrl.substring(0, reqUrl.lastIndexOf("/dr"));
Map<String, String> rvMap = AuthorizationTool.releaseVerification(reqUrlsubStr, "3");
if ("0".equals(rvMap.get("code"))) {
try {
DesensitizationEngineInterfaceImplService engineInterfaceImplService = new DesensitizationEngineInterfaceImplService();
DesensitizationEngineInterfaceImpl engineInterfaceImpl = (DesensitizationEngineInterfaceImpl)engineInterfaceImplService.getPort(DesensitizationEngineInterfaceImpl.class);
List<Object> dataList = new ArrayList();
dataList.add(dataVar);
List<Object> reList = engineInterfaceImpl.dataMaskingListByRuleName(rulename, dataList);
if (null != reList && reList.size() != 0) {
List<Map<String, Object>> tdResultMapList = ApiTool.realObjectsToMaps(reList);
result.put("data", tdResultMapList);
} else {
result.put("code", ResultAPIEnum.RT_ERROR_CODE_403_STR.getCode());
result.put("msg", ResultAPIEnum.RT_ERROR_CODE_403_STR.getMsg());
}
} catch (Exception e) {
System.out.println(">>>>>>>>调用脱敏引擎dataMaskingListByRuleName方法出错..");
result.put("code", ResultAPIEnum.RT_ERROR_CODE_432_STR.getCode());
result.put("msg", ResultAPIEnum.RT_ERROR_CODE_432_STR.getMsg());
e.printStackTrace();
} finally {
String message = JSONObject.toJSONString(result);
ApiInfoLog info = new ApiInfoLog();
info.setApitype("3");
info.setAuthorization(token);
info.setUsername(TokenUtil.getUserId(token));
info.setCalldatetime(new Date());
info.setCreatetime(new Date());
info.setRestatus(String.valueOf(result.get("code")));
info.setRemsg(String.valueOf(result.get("msg")));
info.setUrl(reqUrl);
info.setCilentip(cilentip);
this.apiInfoLogService.save(info);
System.out.println(message);
return message;
}
} else {
result.put("code", ResultAPIEnum.RT_ERROR_CODE_431_STR.getCode());
result.put("msg", rvMap.get("msg"));
String message = JSONObject.toJSONString(result);
ApiInfoLog info = new ApiInfoLog();
info.setApitype("3");
info.setAuthorization(token);
info.setUsername(TokenUtil.getUserId(token));
info.setCalldatetime(new Date());
info.setCreatetime(new Date());
info.setRestatus(String.valueOf(result.get("code")));
info.setRemsg(String.valueOf(result.get("msg")));
info.setUrl(reqUrl);
info.setCilentip(cilentip);
this.apiInfoLogService.save(info);
System.out.println(message);
return message;
}
}
}
}
package com.chenyang.nse.bussiness.engine.ghca.webservice;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(
name = "dataMaskingByRuleName",
propOrder = {"arg0", "arg1"}
)
public class DataMaskingByRuleName {
protected String arg0;
protected Object arg1;
public String getArg0() {
return this.arg0;
}
public void setArg0(String value) {
this.arg0 = value;
}
public Object getArg1() {
return this.arg1;
}
public void setArg1(Object value) {
this.arg1 = value;
}
}
package com.chenyang.nse.bussiness.engine.ghca.webservice;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(
name = "dataMaskingByRuleNameResponse",
propOrder = {"_return"}
)
public class DataMaskingByRuleNameResponse {
@XmlElement(
name = "return"
)
protected Object _return;
public Object getReturn() {
return this._return;
}
public void setReturn(Object value) {
this._return = value;
}
}
package com.chenyang.nse.bussiness.engine.ghca.webservice;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(
name = "dataMaskingListByRuleNameResponse",
propOrder = {"_return"}
)
public class DataMaskingListByRuleNameResponse {
@XmlElement(
name = "return"
)
protected List<Object> _return;
public List<Object> getReturn() {
if (this._return == null) {
this._return = new ArrayList();
}
return this._return;
}
}
package com.chenyang.nse.bussiness.entity.orm.table.core;
import java.util.Date;
public class DataareaSecretkeyRelationVo {
private String encryption_name;
private String secret_key_name;
private String enc_name;
private String encryption_id;
private String secretkey_id;
private String dataarea_id;
private String defaulttype;
private Date createtime;
private Date updatetime;
private String createuser;
private String updateuser;
private String id;
private String flag;
private String note;
public String getEncryption_name() {
return this.encryption_name;
}
public void setEncryption_name(String encryption_name) {
this.encryption_name = encryption_name;
}
public String getSecret_key_name() {
return this.secret_key_name;
}
public void setSecret_key_name(String secret_key_name) {
this.secret_key_name = secret_key_name;
}
public String getEnc_name() {
return this.enc_name;
}
public void setEnc_name(String enc_name) {
this.enc_name = enc_name;
}
public String getEncryption_id() {
return this.encryption_id;
}
public void setEncryption_id(String encryption_id) {
this.encryption_id = encryption_id;
}
public String getSecretkey_id() {
return this.secretkey_id;
}
public void setSecretkey_id(String secretkey_id) {
this.secretkey_id = secretkey_id;
}
public String getDataarea_id() {
return this.dataarea_id;
}
public void setDataarea_id(String dataarea_id) {
this.dataarea_id = dataarea_id;
}
public String getDefaulttype() {
return this.defaulttype;
}
public void setDefaulttype(String defaulttype) {
this.defaulttype = defaulttype;
}
public Date getCreatetime() {
return this.createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public Date getUpdatetime() {
return this.updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getCreateuser() {
return this.createuser;
}
public void setCreateuser(String createuser) {
this.createuser = createuser;
}
public String getUpdateuser() {
return this.updateuser;
}
public void setUpdateuser(String updateuser) {
this.updateuser = updateuser;
}
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getFlag() {
return this.flag;
}
public void setFlag(String flag) {
this.flag = flag;
}
public String getNote() {
return this.note;
}
public void setNote(String note) {
this.note = note;
}
}
package com.chenyang.nse.bussiness.entity.vo;
import java.util.List;
public class DataGridFlagVO<E> {
private long total;
private List<E> rows;
private Integer flag;
public DataGridFlagVO() {
}
public DataGridFlagVO(long total, List<E> rows) {
this.total = total;
this.rows = rows;
}
public long getTotal() {
return this.total;
}
public void setTotal(long total) {
this.total = total;
}
public List<E> getRows() {
return this.rows;
}
public void setRows(List<E> rows) {
this.rows = rows;
}
public Integer getFlag() {
return this.flag;
}
public void setFlag(Integer flag) {
this.flag = flag;
}
}
package com.chenyang.nse.bussiness.entity.vo;
import java.util.List;
public class DataGridVO<E> {
private long total;
private List<E> rows;
public DataGridVO() {
}
public DataGridVO(long total, List<E> rows) {
this.total = total;
this.rows = rows;
}
public long getTotal() {
return this.total;
}
public void setTotal(long total) {
this.total = total;
}
public List<E> getRows() {
return this.rows;
}
public void setRows(List<E> rows) {
this.rows = rows;
}
}
package com.chenyang.nse.bussiness.entity.vo;
import java.util.Date;
public class DataProjectVO {
private String id;
private String flag;
private String note;
private String project;
private Date createtime;
private String createuser;
private String crud;
private String updateuserid;
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getFlag() {
return this.flag;
}
public void setFlag(String flag) {
this.flag = flag;
}
public String getNote() {
return this.note;
}
public void setNote(String note) {
this.note = note;
}
public String getProject() {
return this.project;
}
public void setProject(String project) {
this.project = project;
}
public Date getCreatetime() {
return this.createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public String getCreateuser() {
return this.createuser;
}
public void setCreateuser(String createuser) {
this.createuser = createuser;
}
public String getCrud() {
return this.crud;
}
public void setCrud(String crud) {
this.crud = crud;
}
public String getUpdateuserid() {
return this.updateuserid;
}
public void setUpdateuserid(String updateuserid) {
this.updateuserid = updateuserid;
}
}
package com.chenyang.nse.bussiness.entity.vo;
public class DataScopeEntity {
String schemaName;
String tableName;
String columnName;
String scopeName;
String sensitiveLevel;
String sensitiveName;
String dataareaName;
String classifyid;
String levelid;
String isAuto;
public String getSchemaName() {
return this.schemaName;
}
public String getTableName() {
return this.tableName;
}
public String getColumnName() {
return this.columnName;
}
public String getScopeName() {
return this.scopeName;
}
public String getSensitiveLevel() {
return this.sensitiveLevel;
}
public String getSensitiveName() {
return this.sensitiveName;
}
public String getDataareaName() {
return this.dataareaName;
}
public String getClassifyid() {
return this.classifyid;
}
public String getLevelid() {
return this.levelid;
}
public String getIsAuto() {
return this.isAuto;
}
public void setSchemaName(final String schemaName) {
this.schemaName = schemaName;
}
public void setTableName(final String tableName) {
this.tableName = tableName;
}
public void setColumnName(final String columnName) {
this.columnName = columnName;
}
public void setScopeName(final String scopeName) {
this.scopeName = scopeName;
}
public void setSensitiveLevel(final String sensitiveLevel) {
this.sensitiveLevel = sensitiveLevel;
}
public void setSensitiveName(final String sensitiveName) {
this.sensitiveName = sensitiveName;
}
public void setDataareaName(final String dataareaName) {
this.dataareaName = dataareaName;
}
public void setClassifyid(final String classifyid) {
this.classifyid = classifyid;
}
public void setLevelid(final String levelid) {
this.levelid = levelid;
}
public void setIsAuto(final String isAuto) {
this.isAuto = isAuto;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
} else if (!(o instanceof DataScopeEntity)) {
return false;
} else {
DataScopeEntity other = (DataScopeEntity)o;
if (!other.canEqual(this)) {
return false;
} else {
Object this$schemaName = this.getSchemaName();
Object other$schemaName = other.getSchemaName();
if (this$schemaName == null) {
if (other$schemaName != null) {
return false;
}
} else if (!this$schemaName.equals(other$schemaName)) {
return false;
}
Object this$tableName = this.getTableName();
Object other$tableName = other.getTableName();
if (this$tableName == null) {
if (other$tableName != null) {
return false;
}
} else if (!this$tableName.equals(other$tableName)) {
return false;
}
Object this$columnName = this.getColumnName();
Object other$columnName = other.getColumnName();
if (this$columnName == null) {
if (other$columnName != null) {
return false;
}
} else if (!this$columnName.equals(other$columnName)) {
return false;
}
Object this$scopeName = this.getScopeName();
Object other$scopeName = other.getScopeName();
if (this$scopeName == null) {
if (other$scopeName != null) {
return false;
}
} else if (!this$scopeName.equals(other$scopeName)) {
return false;
}
Object this$sensitiveLevel = this.getSensitiveLevel();
Object other$sensitiveLevel = other.getSensitiveLevel();
if (this$sensitiveLevel == null) {
if (other$sensitiveLevel != null) {
return false;
}
} else if (!this$sensitiveLevel.equals(other$sensitiveLevel)) {
return false;
}
Object this$sensitiveName = this.getSensitiveName();
Object other$sensitiveName = other.getSensitiveName();
if (this$sensitiveName == null) {
if (other$sensitiveName != null) {
return false;
}
} else if (!this$sensitiveName.equals(other$sensitiveName)) {
return false;
}
Object this$dataareaName = this.getDataareaName();
Object other$dataareaName = other.getDataareaName();
if (this$dataareaName == null) {
if (other$dataareaName != null) {
return false;
}
} else if (!this$dataareaName.equals(other$dataareaName)) {
return false;
}
Object this$classifyid = this.getClassifyid();
Object other$classifyid = other.getClassifyid();
if (this$classifyid == null) {
if (other$classifyid != null) {
return false;
}
} else if (!this$classifyid.equals(other$classifyid)) {
return false;
}
Object this$levelid = this.getLevelid();
Object other$levelid = other.getLevelid();
if (this$levelid == null) {
if (other$levelid != null) {
return false;
}
} else if (!this$levelid.equals(other$levelid)) {
return false;
}
Object this$isAuto = this.getIsAuto();
Object other$isAuto = other.getIsAuto();
if (this$isAuto == null) {
if (other$isAuto != null) {
return false;
}
} else if (!this$isAuto.equals(other$isAuto)) {
return false;
}
return true;
}
}
}
protected boolean canEqual(final Object other) {
return other instanceof DataScopeEntity;
}
public int hashCode() {
int PRIME = 59;
int result = 1;
Object $schemaName = this.getSchemaName();
result = result * 59 + ($schemaName == null ? 43 : $schemaName.hashCode());
Object $tableName = this.getTableName();
result = result * 59 + ($tableName == null ? 43 : $tableName.hashCode());
Object $columnName = this.getColumnName();
result = result * 59 + ($columnName == null ? 43 : $columnName.hashCode());
Object $scopeName = this.getScopeName();
result = result * 59 + ($scopeName == null ? 43 : $scopeName.hashCode());
Object $sensitiveLevel = this.getSensitiveLevel();
result = result * 59 + ($sensitiveLevel == null ? 43 : $sensitiveLevel.hashCode());
Object $sensitiveName = this.getSensitiveName();
result = result * 59 + ($sensitiveName == null ? 43 : $sensitiveName.hashCode());
Object $dataareaName = this.getDataareaName();
result = result * 59 + ($dataareaName == null ? 43 : $dataareaName.hashCode());
Object $classifyid = this.getClassifyid();
result = result * 59 + ($classifyid == null ? 43 : $classifyid.hashCode());
Object $levelid = this.getLevelid();
result = result * 59 + ($levelid == null ? 43 : $levelid.hashCode());
Object $isAuto = this.getIsAuto();
result = result * 59 + ($isAuto == null ? 43 : $isAuto.hashCode());
return result;
}
public String toString() {
return "DataScopeEntity(schemaName=" + this.getSchemaName() + ", tableName=" + this.getTableName() + ", columnName=" + this.getColumnName() + ", scopeName=" + this.getScopeName() + ", sensitiveLevel=" + this.getSensitiveLevel() + ", sensitiveName=" + this.getSensitiveName() + ", dataareaName=" + this.getDataareaName() + ", classifyid=" + this.getClassifyid() + ", levelid=" + this.getLevelid() + ", isAuto=" + this.getIsAuto() + ")";
}
}
package com.chenyang.nse.bussiness.entity.vo.datamap;
import com.chenyang.nse.bussiness.entity.orm.table.core.datamap.TCoreDatamapTable;
import com.chenyang.nse.bussiness.entity.orm.table.core.datamap.TCoreDatamapTablerelation;
import java.util.List;
public class DataMapVO {
private String tablecount;
private String fkcount;
private List<TCoreDatamapTable> nodes;
private List<TCoreDatamapTablerelation> edges;
public DataMapVO() {
}
public DataMapVO(String tablecount, String fkcount, List<TCoreDatamapTable> nodes, List<TCoreDatamapTablerelation> edges) {
this.tablecount = tablecount;
this.fkcount = fkcount;
this.nodes = nodes;
this.edges = edges;
}
public String getTablecount() {
return this.tablecount;
}
public void setTablecount(String tablecount) {
this.tablecount = tablecount;
}
public String getFkcount() {
return this.fkcount;
}
public void setFkcount(String fkcount) {
this.fkcount = fkcount;
}
public List<TCoreDatamapTable> getNodes() {
return this.nodes;
}
public void setNodes(List<TCoreDatamapTable> nodes) {
this.nodes = nodes;
}
public List<TCoreDatamapTablerelation> getEdges() {
return this.edges;
}
public void setEdges(List<TCoreDatamapTablerelation> edges) {
this.edges = edges;
}
public String toString() {
return "TableRelationVO [tablecount=" + this.tablecount + ", fkcount=" + this.fkcount + ", nodes=" + this.nodes + ", edges=" + this.edges + "]";
}
public int hashCode() {
int prime = 31;
int result = 1;
result = 31 * result + (this.edges == null ? 0 : this.edges.hashCode());
result = 31 * result + (this.fkcount == null ? 0 : this.fkcount.hashCode());
result = 31 * result + (this.nodes == null ? 0 : this.nodes.hashCode());
result = 31 * result + (this.tablecount == null ? 0 : this.tablecount.hashCode());
return result;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
} else if (obj == null) {
return false;
} else if (this.getClass() != obj.getClass()) {
return false;
} else {
DataMapVO other = (DataMapVO)obj;
if (this.edges == null) {
if (other.edges != null) {
return false;
}
} else if (!this.edges.equals(other.edges)) {
return false;
}
if (this.fkcount == null) {
if (other.fkcount != null) {
return false;
}
} else if (!this.fkcount.equals(other.fkcount)) {
return false;
}
if (this.nodes == null) {
if (other.nodes != null) {
return false;
}
} else if (!this.nodes.equals(other.nodes)) {
return false;
}
if (this.tablecount == null) {
if (other.tablecount != null) {
return false;
}
} else if (!this.tablecount.equals(other.tablecount)) {
return false;
}
return true;
}
}
}
package com.chenyang.nse.bussiness.init;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chenyang.nse.bussiness.entity.vo.ReturnInterfaceDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
@Component
@Order(3)
@RequestMapping({"datainitload"})
public class DataInitLoad implements ApplicationRunner {
public static boolean initCacheFlag = false;
@Value("${classify.classifyEnable}")
boolean classifyEnable;
@Value("${classify.url}")
String classifyIpAndPort;
@Value("${classify.classifyName}")
String classifyName;
@Value("${classify.levelName}")
String levelName;
public static final int PAGE_SIZE = 10000;
public void run(ApplicationArguments args) throws Exception {
(new Thread(() -> {
try {
if (this.classifyEnable) {
try {
this.initClassifyInfos();
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
})).start();
}
@RequestMapping({"initClassifyInfos"})
public void initClassifyInfos() {
try {
this.initClassifyAndLevel();
} catch (Exception e) {
e.printStackTrace();
}
this.initColumnAndClassifyAndLevelAndAreaRelation();
}
public void initClassifyAndLevel() {
String classifyUrl = this.classifyIpAndPort + this.classifyName;
String levelUrl = this.classifyIpAndPort + this.levelName;
String jsonBody = "{\"edition_id\": \"1\",\"type\":\"0\"}";
String jsonBody2 = "{\"edition_id\": \"1\",\"type\":\"1\"}";
try {
String classifyRes = sendHttpPost(classifyUrl, jsonBody);
Map classifyMap = (Map)JSON.parse(classifyRes);
List<Map<String, Object>> classifyList = (List)classifyMap.get("data");
StaticDatasPool.allCtrlClassifyList = classifyList;
String levelRes = sendHttpPost(levelUrl, jsonBody);
Map levelMap = (Map)JSON.parse(levelRes);
List<Map> levelList = (List)levelMap.get("data");
StaticDatasPool.allCtrlLevelList = levelList;
String classifyRes2 = sendHttpPost(classifyUrl, jsonBody2);
Map classifyMap2 = (Map)JSON.parse(classifyRes2);
List<Map> classifyList2 = (List)classifyMap2.get("data");
StaticDatasPool.allColumnClassifyList = classifyList2;
String levelRes2 = sendHttpPost(levelUrl, jsonBody2);
Map levelMap2 = (Map)JSON.parse(levelRes2);
List<Map> levelList2 = (List)levelMap2.get("data");
StaticDatasPool.allColumnLevelList = levelList2;
} catch (Exception e) {
e.printStackTrace();
}
}
public static String sendHttpPost(String url, String JSONBody) throws Exception {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
httpPost.addHeader("Content-Type", "application/json");
httpPost.setEntity(new StringEntity(JSONBody));
CloseableHttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
String responseContent = EntityUtils.toString(entity, "UTF-8");
response.close();
httpClient.close();
return responseContent;
}
public void initColumnAndClassifyAndLevelAndAreaRelation() {
String url = this.classifyIpAndPort + "/core/datascope/getScopeAndSensitiveInfo";
String jsonBody = "";
try {
String classifyRes = sendHttpPost(url, jsonBody);
Map result = (Map)JSON.parse(classifyRes);
Map map = (Map)result.get("data");
List<ReturnInterfaceDate> list = new ArrayList();
if (map != null && map.size() > 0) {
list = JSON.parseArray(JSONObject.toJSONString(map.get("allInfo")), ReturnInterfaceDate.class);
}
StaticDatasPool.columnAndClassifyAndLevelAndAreaRelationList = list;
} catch (Exception e) {
e.printStackTrace();
}
}
public void changeColumnAndClassifyAndLevelAndAreaRelation(String dataSystemId, String schemaName, String tableName, String columnName) {
String url = this.classifyIpAndPort + "/core/datascope/getScopeAndSensitiveInfoForPush";
String jsonBody = "{\"dataSystemId\": \"" + dataSystemId + "\",\"schemaName\": \"" + schemaName + "\",\"tableName\": \"" + tableName + "\",\"columnName\": \"" + columnName + "\"}";
try {
String classifyRes = sendHttpPost(url, jsonBody);
Map result = (Map)JSON.parse(classifyRes);
Map map = (Map)result.get("data");
List<ReturnInterfaceDate> list = (List)map.get("list");
StaticDatasPool.columnAndClassifyAndLevelAndAreaRelationList = list;
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.chenyang.nse.bussiness.kms.controller;
import com.chenyang.nse.bussiness.kms.model.Kms;
import com.chenyang.nse.bussiness.kms.service.KmsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping({"kms"})
public class DataKeyController {
protected Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
protected KmsService kmsService;
@RequestMapping({"datakey"})
public String dataKey() {
return this.kmsService.createDataKey(Kms.MasterKey.getInstance().getKeyid(), this.kmsService.obtainAccessToken(this.kmsService.obtainChallengeCode()));
}
}
package com.chenyang.nse.bussiness.service.console.impl;
import com.chenyang.nse.bussiness.dao.table.console.mapping.TConsoleDatamappingInfoDao;
import com.chenyang.nse.bussiness.dao.table.console.mapping.TConsoleDatamappingTargetfieldDao;
import com.chenyang.nse.bussiness.entity.orm.table.console.mapping.TConsoleDatamappingInfo;
import com.chenyang.nse.bussiness.entity.orm.table.console.mapping.TConsoleDatamappingTargetfield;
import com.chenyang.nse.bussiness.service.console.DataMappingService;
import java.util.List;
import java.util.Map;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
public class DataMappingServiceImpl implements DataMappingService {
@Autowired
private TConsoleDatamappingInfoDao tConsoleDatamappingInfoDao;
@Autowired
private TConsoleDatamappingTargetfieldDao tConsoleDatamappingTargetfieldDao;
public List<Map<String, String>> getDatamappingInfo(String sourcesystemtype, String targetsystemtype) {
List<Map<String, String>> list = this.tConsoleDatamappingInfoDao.getDatamappingInfo(sourcesystemtype, targetsystemtype);
return list;
}
public List<TConsoleDatamappingTargetfield> getTargetFieldByType(String datasystemtype) {
List<TConsoleDatamappingTargetfield> list = this.tConsoleDatamappingTargetfieldDao.queryAll("fieldname", true, new Criterion[]{Restrictions.eq("datasystemtype", datasystemtype)});
return list;
}
public void modifyDataInfo(Map<String, String> map) {
String id = (String)map.get("id");
String sourcefieldid = (String)map.get("sourcefieldid");
String flag = (String)map.get("flag");
String targetfieldid = (String)map.get("targetfieldid");
String targetlength = (String)map.get("targetlength");
String targetdecimal = (String)map.get("targetdecimal");
String targetsystemtype = (String)map.get("targetsystemtype");
String note = (String)map.get("note");
TConsoleDatamappingInfo tConsoleDatamappingInfo = new TConsoleDatamappingInfo();
if (id != "" && id != null) {
tConsoleDatamappingInfo.setId(id);
}
tConsoleDatamappingInfo.setSourcefieldid(sourcefieldid);
tConsoleDatamappingInfo.setFlag(flag);
tConsoleDatamappingInfo.setTargetfieldid(targetfieldid);
tConsoleDatamappingInfo.setTargetlength(flag.equals("1") ? targetlength : "");
tConsoleDatamappingInfo.setTargetdecimal(flag.equals("1") ? targetdecimal : "");
tConsoleDatamappingInfo.setTargetsystemtype(targetsystemtype);
tConsoleDatamappingInfo.setNote(note);
this.tConsoleDatamappingInfoDao.saveOrUpdate(tConsoleDatamappingInfo);
}
}
package com.chenyang.nse.bussiness.service.core;
import com.chenyang.nse.bussiness.dao.PageInfo;
import com.chenyang.nse.bussiness.entity.orm.table.core.TCoreDataPreviewSQL;
import com.chenyang.nse.bussiness.entity.orm.table.core.TCoreDatasystem;
import com.chenyang.nse.bussiness.entity.vo.DataPreviewVO;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
public interface DataPreviewService {
DataPreviewVO queryDataPreviewBysql(PageInfo pageInfo, DataPreviewVO dataPreviewVO);
List<TCoreDataPreviewSQL> queryDataPreviewHis(String datasystem_id);
String esQueryDataPreview(TCoreDatasystem tCoreDatasystem, String essql);
}
package com.chenyang.nse.bussiness.service.core;
import com.chenyang.nse.bussiness.dao.PageInfo;
import com.chenyang.nse.bussiness.entity.orm.table.core.fieldscope.view.TNumDatasystem;
import com.chenyang.nse.bussiness.entity.orm.table.core.fieldscope.view.TNumDescription;
import com.chenyang.nse.bussiness.entity.orm.table.core.fieldscope.view.TNumProject;
import com.chenyang.nse.bussiness.entity.orm.table.core.fieldscope.view.TNumSchema;
import com.chenyang.nse.bussiness.entity.orm.table.core.fieldscope.view.TNumTable;
import java.util.List;
public interface DataScopeCharsService {
List<TNumProject> getProjectlistRuleReport(PageInfo pageInfo, String project_name, String type);
List<TNumDescription> getDescriptionlistRuleReport(PageInfo pageInfo, String project_name, String description_name, String type);
List<TNumDatasystem> getDatasystemlistRuleReport(PageInfo pageInfo, String project_name, String description_name, String datasystem_name, String type);
List<TNumSchema> getSchemalistRuleReport(PageInfo pageInfo, String project_name, String description_name, String datasystem_name, String schema_name, String type);
List<TNumTable> getTablelistRuleReport(PageInfo pageInfo, String project_name, String description_name, String datasystem_name, String schema_name, String table_name, String type);
}
package com.chenyang.nse.bussiness.service.core.backup;
import com.chenyang.nse.bussiness.entity.vo.dataproject.TCoreDataBackUpVO;
public interface DataBackUpService {
String checkTable(TCoreDataBackUpVO params);
void dataSync(TCoreDataBackUpVO params);
}
package com.chenyang.nse.bussiness.service.core.impl;
import com.chenyang.nse.bussiness.dao.core.DataMapDao;
import com.chenyang.nse.bussiness.dao.table.core.TCoreDatasystemDao;
import com.chenyang.nse.bussiness.dao.table.core.datamap.TCoreDatamapColumnDao;
import com.chenyang.nse.bussiness.dao.table.core.datamap.TCoreDatamapDao;
import com.chenyang.nse.bussiness.dao.table.core.datamap.TCoreDatamapForeignkeyDao;
import com.chenyang.nse.bussiness.dao.table.core.datamap.TCoreDatamapTableDao;
import com.chenyang.nse.bussiness.dao.table.core.datamap.TCoreDatamapTablealiasDao;
import com.chenyang.nse.bussiness.dao.table.core.datamap.TCoreDatamapTablerelationDao;
import com.chenyang.nse.bussiness.dao.table.core.datamap.TCoreDatamapUsermapDao;
import com.chenyang.nse.bussiness.dao.table.core.masking.TCoreMaskingTableDao;
import com.chenyang.nse.bussiness.dao.table.core.masking.TCoreMaskingTablecolumnDao;
import com.chenyang.nse.bussiness.dao.table.core.masking.TCoreMaskingTaskDao;
import com.chenyang.nse.bussiness.entity.db.ColumnInfo;
import com.chenyang.nse.bussiness.entity.db.ForeignKeyInfo;
import com.chenyang.nse.bussiness.entity.db.TableInfo;
import com.chenyang.nse.bussiness.entity.orm.table.core.TCoreDatasystem;
import com.chenyang.nse.bussiness.entity.orm.table.core.datamap.TCoreDatamap;
import com.chenyang.nse.bussiness.entity.orm.table.core.datamap.TCoreDatamapColumn;
import com.chenyang.nse.bussiness.entity.orm.table.core.datamap.TCoreDatamapTable;
import com.chenyang.nse.bussiness.entity.orm.table.core.datamap.TCoreDatamapTablealias;
import com.chenyang.nse.bussiness.entity.orm.table.core.datamap.TCoreDatamapTablerelation;
import com.chenyang.nse.bussiness.entity.orm.table.core.datamap.TCoreDatamapUsermap;
import com.chenyang.nse.bussiness.entity.orm.table.core.masking.TCoreMaskingTable;
import com.chenyang.nse.bussiness.entity.orm.table.core.masking.TCoreMaskingTablecolumn;
import com.chenyang.nse.bussiness.entity.orm.table.core.masking.TCoreMaskingTask;
import com.chenyang.nse.bussiness.entity.vo.TreeVO;
import com.chenyang.nse.bussiness.enumeration.EdataSystemGrade;
import com.chenyang.nse.bussiness.enumeration.EdbType;
import com.chenyang.nse.bussiness.enumeration.EmaskingDirection;
import com.chenyang.nse.bussiness.enumeration.EmaskingTaskType;
import com.chenyang.nse.bussiness.service.core.DataMapService;
import com.chenyang.nse.bussiness.tools.jdbc.JdbcTool;
import com.chenyang.nse.bussiness.tools.number.IntegerTool;
import com.chenyang.nse.bussiness.tools.other.ColorTool;
import com.chenyang.nse.bussiness.tools.string.AesTool;
import com.chenyang.nse.bussiness.tools.string.StringTool;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
public class DataMapServiceImpl implements DataMapService {
@Autowired
private TCoreDatasystemDao tCoreDatasystemDao;
@Autowired
private TCoreDatamapDao tCoreDatamapDao;
@Autowired
private TCoreDatamapTableDao tCoreDatamapTableDao;
@Autowired
private TCoreDatamapForeignkeyDao tCoreDatamapForeignkeyDao;
@Autowired
private TCoreDatamapColumnDao tCoreDatamapColumnDao;
@Autowired
private TCoreDatamapTablerelationDao tCoreDatamapTablerelationDao;
@Autowired
private TCoreDatamapUsermapDao tCoreDatamapUsermapDao;
@Autowired
private TCoreDatamapTablealiasDao tCoreDatamapTablealiasDao;
@Autowired
private TCoreMaskingTaskDao tCoreMaskingTaskDao;
@Autowired
private DataMapDao dataMapDao;
@Autowired
private TCoreMaskingTableDao tCoreMaskingTableDao;
@Autowired
private TCoreMaskingTablecolumnDao tCoreMaskingTablecolumnDao;
public Connection getConnectionByDataSystemId(String datasystemid) {
TCoreDatasystem datasystem = (TCoreDatasystem)this.tCoreDatasystemDao.get(datasystemid);
String dbcode = datasystem.getDbtype();
String ip = datasystem.getDbip();
String port = datasystem.getDbport();
String servername = datasystem.getDbservername();
String url = EdbType.getUrlByEdbcode(dbcode, ip, port, servername);
String username = datasystem.getUsername();
String password = AesTool.decrypt(datasystem.getPassword(), "ghca");
String driver = EdbType.getEdbTypeByDbcode(dbcode).getDbdriver();
Connection conn = JdbcTool.getConnection(driver, url, username, password);
return conn;
}
public TCoreDatamap queryDataMapUnique(String datasystemid, String dbschema) {
TCoreDatamap dataMap = (TCoreDatamap)this.tCoreDatamapDao.queryUnique(new Criterion[]{Restrictions.eq("datasystemid", datasystemid), Restrictions.eq("dbschema", dbschema)});
return dataMap;
}
public void generateDataMap(String datasystemid, String schema) {
TCoreDatamap dataMap = new TCoreDatamap(datasystemid, schema, new Date());
this.tCoreDatamapDao.save(dataMap);
String dataMapId = dataMap.getId();
TCoreDatasystem dataSystem = (TCoreDatasystem)this.tCoreDatasystemDao.get(datasystemid);
String url = EdbType.getUrlByEdbcode(dataSystem.getDbtype(), dataSystem.getDbip(), dataSystem.getDbport(), dataSystem.getDbservername());
Connection conn = JdbcTool.getConnection(EdbType.getEdbTypeByDbcode(dataSystem.getDbtype()).getDbdriver(), url, dataSystem.getUsername(), AesTool.decrypt(dataSystem.getPassword(), "ghca"));
for(TableInfo tableInfo : JdbcTool.getTableInfoByConnection(conn, schema, (String)null)) {
TCoreDatamapTable dataMapTable = new TCoreDatamapTable(ColorTool.randomColor(), tableInfo.getTablename(), String.valueOf(IntegerTool.randomInt(-3000, 3000)), String.valueOf(IntegerTool.randomInt(-2000, 2000)), String.valueOf(IntegerTool.randomInt(20, 40)), dataMapId, (String)null, (String)null);
String tableNote = JdbcTool.queryTableNote(conn, schema, tableInfo.getTablename());
TCoreDatamapTablealias tableAlias = this.tCoreDatamapTablealiasDao.queryDataMapTableAlias(datasystemid, schema, tableInfo.getTablename());
if (tableAlias != null) {
dataMapTable.setByname(tableAlias.getTablebyname());
}
dataMapTable.setNote(tableNote);
this.tCoreDatamapTableDao.save(dataMapTable);
for(ColumnInfo columnInfo : tableInfo.getColumninfos()) {
TCoreDatamapColumn dataMapColumn = new TCoreDatamapColumn(dataMapId, columnInfo.getColumnname(), columnInfo.getTypename(), columnInfo.getColumnsize(), dataMapTable.getId());
dataMapColumn.setNote(columnInfo.getRemarks());
this.tCoreDatamapColumnDao.save(dataMapColumn);
}
}
List<ForeignKeyInfo> foreignkey = JdbcTool.queryForeignKey(conn, schema);
if (foreignkey != null && foreignkey.size() != 0) {
for(ForeignKeyInfo foreignKey : foreignkey) {
TCoreDatamapTable sourcetable = this.tCoreDatamapTableDao.queryDataMapTable(dataMapId, foreignKey.getPktable());
TCoreDatamapTable targettable = this.tCoreDatamapTableDao.queryDataMapTable(dataMapId, foreignKey.getFktable());
if (sourcetable != null && targettable != null) {
boolean exist = this.tCoreDatamapTablerelationDao.isRelationExist(dataMapId, sourcetable.getId(), targettable.getId());
if (!exist) {
this.tCoreDatamapTablerelationDao.save(new TCoreDatamapTablerelation(sourcetable.getId(), targettable.getId(), "1", dataMapId));
}
}
}
}
}
public void removeDataMap(String datamapid) {
this.tCoreDatamapTableDao.remove(new Criterion[]{Restrictions.eq("datamapid", datamapid)});
this.tCoreDatamapForeignkeyDao.remove(new Criterion[]{Restrictions.eq("datamapid", datamapid)});
this.tCoreDatamapTablerelationDao.remove(new Criterion[]{Restrictions.eq("datamapid", datamapid)});
this.tCoreDatamapColumnDao.remove(new Criterion[]{Restrictions.eq("datamapid", datamapid)});
this.tCoreDatamapDao.removeById(datamapid);
}
public void removeDataMap(String datasystemid, String schema) {
TCoreDatamap datamap = this.queryDataMapUnique(datasystemid, schema);
if (datamap != null) {
this.removeDataMap(datamap.getId());
}
}
public List<TCoreDatamapTablerelation> queryDataMapTableRelation(String datamapid) {
List<TCoreDatamapTablerelation> list = this.tCoreDatamapTablerelationDao.queryAll(new Criterion[]{Restrictions.eq("datamapid", datamapid)});
return list;
}
public TCoreDatamapTablealias setTableAlias(String datasystemid, String schema, String table, String alias) {
TCoreDatamapTablealias tableAlias = this.tCoreDatamapTablealiasDao.queryDataMapTableAlias(datasystemid, schema, table);
if (tableAlias != null) {
tableAlias.setTablebyname(alias);
this.tCoreDatamapTablealiasDao.saveOrUpdate(tableAlias);
return tableAlias;
} else {
tableAlias = new TCoreDatamapTablealias(datasystemid, schema, table, alias);
this.tCoreDatamapTablealiasDao.save(tableAlias);
return tableAlias;
}
}
public void synchronizeDataMapTableAlias(TCoreDatamapTablealias tableAlias) {
TCoreDatamap dataMap = this.queryDataMapUnique(tableAlias.getDatasystemid(), tableAlias.getDbschema());
if (dataMap != null) {
TCoreDatamapTable dataMapTable = this.tCoreDatamapTableDao.queryDataMapTable(dataMap.getId(), tableAlias.getTablename());
if (dataMapTable != null) {
dataMapTable.setByname(tableAlias.getTablebyname());
this.tCoreDatamapTableDao.saveOrUpdate(dataMapTable);
}
}
}
public List<TCoreDatamapTable> queryDataMapTable(String datamapid) {
List<TCoreDatamapTable> list = this.tCoreDatamapTableDao.queryAll(new Criterion[]{Restrictions.eq("datamapid", datamapid)});
return list;
}
public TCoreDatamapTable queryDataMapTable(String datasystemid, String schema, String table) {
TCoreDatamap dataMap = this.queryDataMapUnique(datasystemid, schema);
if (dataMap == null) {
return null;
} else {
TCoreDatamapTable dataMapTable = this.tCoreDatamapTableDao.queryDataMapTable(dataMap.getId(), table);
return dataMapTable;
}
}
public TCoreDatamapTable queryDataMapTableById(String tableid) {
TCoreDatamapTable table = (TCoreDatamapTable)this.tCoreDatamapTableDao.get(tableid);
return table;
}
public List<TCoreDatamapColumn> queryDataMapColumnById(String tablerelationid) {
List<TCoreDatamapColumn> list = this.tCoreDatamapColumnDao.queryAll(new Criterion[]{Restrictions.eq("datamaptableid", tablerelationid)});
return list;
}
public List<TCoreDatamapTable> queryDataMapTable(String datamapid, String excludetable) {
List<TCoreDatamapTable> list = this.tCoreDatamapTableDao.queryAll(new Criterion[]{Restrictions.eq("datamapid", datamapid), Restrictions.ne("tablename", excludetable)});
return list;
}
public TCoreDatamapTablerelation queryTableRelation(String datamapid, String sourcetableid, String targettableid) {
TCoreDatamapTablerelation relation = this.tCoreDatamapTablerelationDao.queryTableRelation(datamapid, sourcetableid, targettableid);
if (relation != null) {
return relation;
} else {
relation = this.tCoreDatamapTablerelationDao.queryTableRelation(datamapid, targettableid, sourcetableid);
return relation;
}
}
public void saveDataMapTableRelation(String datamapid, String sourcetableid, String targettableid) {
this.tCoreDatamapTablerelationDao.save(new TCoreDatamapTablerelation(sourcetableid, targettableid, "1", datamapid));
}
public void saveDataMapUserMap(TCoreDatamapUsermap usermap) {
TCoreDatamapUsermap temp = this.tCoreDatamapUsermapDao.queryUnique(usermap.getUserid(), usermap.getTableid());
if (temp == null) {
this.tCoreDatamapUsermapDao.save(usermap);
}
}
public List<TreeVO> initTree(String flag, String code, String text, String parentid, String alias, String userid) {
List<TreeVO> tree_datasystem = new ArrayList();
if (code != null && code.equals(EdataSystemGrade.DATASYSTEM.getCode())) {
for(TCoreDatasystem item : this.tCoreDatasystemDao.queryAll(new Criterion[]{Restrictions.eq("flag", flag)})) {
tree_datasystem.add(new TreeVO(item.getId(), item.getSysname(), "closed", TreeVO.CHECKED_FALSE, EdataSystemGrade.DATASYSTEM.getCode(), "icon-db", (List)null));
}
return tree_datasystem;
} else if (code != null && code.equals(EdataSystemGrade.SCHEMA.getCode())) {
Connection conn = this.getConnectionByDataSystemId(parentid);
List<String> schemalist = JdbcTool.getDbSchemas(conn);
JdbcTool.closeConnection(conn);
for(String item : schemalist) {
tree_datasystem.add(new TreeVO(parentid + item, item, "closed", TreeVO.CHECKED_FALSE, EdataSystemGrade.SCHEMA.getCode(), "icon-folder", (List)null));
}
return tree_datasystem;
} else if (code != null && code.equals(EdataSystemGrade.TABLE.getCode())) {
String datasystemid = parentid.replace(text, "");
Connection conn = this.getConnectionByDataSystemId(datasystemid);
List<String> tablelist = JdbcTool.getAllTableName(conn, text);
JdbcTool.closeConnection(conn);
TCoreDatamap dataMap = this.queryDataMapUnique(datasystemid, text);
List<String> tableNameList = null;
if (dataMap != null) {
tableNameList = this.dataMapDao.queryUserMapTableName(dataMap.getId(), userid);
}
for(String item : tablelist) {
TreeVO tabletree = new TreeVO(parentid + item, item, "open", TreeVO.CHECKED_FALSE, EdataSystemGrade.TABLE.getCode(), "icon-table", (List)null);
tabletree.setNodename(item);
if ("1".equals(alias)) {
TCoreDatamapTablealias tableAlias = this.tCoreDatamapTablealiasDao.queryDataMapTableAlias(datasystemid, text, item);
if (tableAlias != null && !"".equals(tableAlias.getTablebyname().trim())) {
tabletree.setNodebyname(tableAlias.getTablebyname().trim());
}
if (tableNameList != null && tableNameList.size() > 0 && tableNameList.contains(item)) {
tabletree.setIconCls("icon-user-table");
}
}
tree_datasystem.add(tabletree);
}
return tree_datasystem;
} else {
return null;
}
}
public List<TreeVO> initUserTree(String flag, String code, String text, String parentid, String alias, String userid) {
List<TreeVO> tree_datasystem = new ArrayList();
if (code != null && code.equals(EdataSystemGrade.DATASYSTEM.getCode())) {
List<String> dataSystemIdList = this.dataMapDao.queryUserMapDataSystemId(userid);
for(TCoreDatasystem item : this.tCoreDatasystemDao.queryAll(new Criterion[]{Restrictions.in("id", dataSystemIdList)})) {
tree_datasystem.add(new TreeVO(item.getId(), item.getSysname(), "closed", TreeVO.CHECKED_FALSE, EdataSystemGrade.DATASYSTEM.getCode(), "icon-db", (List)null));
}
return tree_datasystem;
} else if (code != null && code.equals(EdataSystemGrade.SCHEMA.getCode())) {
List<String> schemaList = this.dataMapDao.queryUserMapSchema(userid, parentid);
Connection conn = this.getConnectionByDataSystemId(parentid);
List<String> schemalist = JdbcTool.getDbSchemas(conn);
JdbcTool.closeConnection(conn);
for(String item : schemalist) {
if (schemaList != null && schemaList.size() > 0 && schemaList.contains(item)) {
tree_datasystem.add(new TreeVO(parentid + item, item, "closed", TreeVO.CHECKED_FALSE, EdataSystemGrade.SCHEMA.getCode(), "icon-folder", (List)null));
}
}
return tree_datasystem;
} else if (code != null && code.equals(EdataSystemGrade.TABLE.getCode())) {
String datasystemid = parentid.replace(text, "");
Connection conn = this.getConnectionByDataSystemId(datasystemid);
List<String> tablelist = JdbcTool.getAllTableName(conn, text);
JdbcTool.closeConnection(conn);
TCoreDatamap dataMap = this.queryDataMapUnique(datasystemid, text);
List<String> tableNameList = null;
if (dataMap != null) {
tableNameList = this.dataMapDao.queryUserMapTableName(dataMap.getId(), userid);
}
for(String item : tablelist) {
TreeVO tabletree = new TreeVO(parentid + item, item, "open", TreeVO.CHECKED_FALSE, EdataSystemGrade.TABLE.getCode(), "icon-table", (List)null);
tabletree.setNodename(item);
if ("1".equals(alias)) {
TCoreDatamapTablealias tableAlias = this.tCoreDatamapTablealiasDao.queryDataMapTableAlias(datasystemid, text, item);
if (tableAlias != null && !"".equals(tableAlias.getTablebyname().trim())) {
tabletree.setNodebyname(tableAlias.getTablebyname().trim());
}
if (tableNameList != null && tableNameList.size() > 0 && tableNameList.contains(item)) {
tabletree.setIconCls("icon-user-table");
tree_datasystem.add(tabletree);
}
}
}
return tree_datasystem;
} else {
return null;
}
}
public List<TCoreDatamapTable> queryDataMapUserTable(String datamapid, String userid) {
List<String> tableIdList = this.dataMapDao.queryTableId(datamapid, userid);
List<TCoreDatamapTable> list = this.tCoreDatamapTableDao.queryAll(new Criterion[]{Restrictions.in("id", tableIdList)});
return list;
}
public List<TCoreDatamapTable> queryDataMapUserTable(String datamapid, String userid, String excludetable) {
List<String> tableIdList = this.dataMapDao.queryTableId(datamapid, userid);
List<TCoreDatamapTable> list = this.tCoreDatamapTableDao.queryAll(new Criterion[]{Restrictions.in("id", tableIdList), Restrictions.ne("tablename", excludetable)});
return list;
}
public void removeUserMap(String datamapid, String tableid, String userid) {
this.tCoreDatamapUsermapDao.remove(new Criterion[]{Restrictions.eq("datamapid", datamapid), Restrictions.eq("tableid", tableid), Restrictions.eq("userid", userid)});
}
public void saveTableNote(TCoreDatamapTable table) {
String note = table.getNote();
table = (TCoreDatamapTable)this.tCoreDatamapTableDao.get(table.getId());
table.setNote(note);
this.tCoreDatamapTableDao.save(table);
}
public void saveColumnNote(TCoreDatamapColumn column) {
String note = column.getNote();
column = (TCoreDatamapColumn)this.tCoreDatamapColumnDao.get(column.getId());
column.setNote(note);
this.tCoreDatamapColumnDao.save(column);
}
public TCoreDatamap queryDataMap(String datamapid) {
return (TCoreDatamap)this.tCoreDatamapDao.get(datamapid);
}
public TCoreMaskingTask queryMaskingTask(String engineid, String taskname) {
TCoreMaskingTask task = (TCoreMaskingTask)this.tCoreMaskingTaskDao.queryUnique(new Criterion[]{Restrictions.eq("engineid", engineid), Restrictions.eq("taskname", taskname)});
return task;
}
public TCoreMaskingTask saveTask(String userid, String engineid, String folderName, String taskname, String note, String tableid, String datatargetid, String datatargetschema, String targetTableName) {
TCoreDatamapTable maptable = (TCoreDatamapTable)this.tCoreDatamapTableDao.get(tableid);
TCoreDatamap datamap = (TCoreDatamap)this.tCoreDatamapDao.get(maptable.getDatamapid());
TCoreDatasystem datasystem = (TCoreDatasystem)this.tCoreDatasystemDao.get(datamap.getDatasystemid());
Connection sourceConnection = this.getConnectionByDataSystemId(datamap.getDatasystemid());
Connection targetConnection = this.getConnectionByDataSystemId(datatargetid);
JdbcTool.copyTable(sourceConnection, datamap.getDbschema(), maptable.getTablename(), targetConnection, datatargetschema, targetTableName);
JdbcTool.closeConnection(sourceConnection);
JdbcTool.closeConnection(targetConnection);
TCoreMaskingTask task = new TCoreMaskingTask(taskname, new Date(), userid, engineid, folderName, (String)null, (String)null, (String)null, (String)null, (String)null, (String)null, (String)null, (String)null, (String)null);
task.setNote(note);
task.setFlag(EmaskingTaskType.DB_TO_DB.getFlag());
this.tCoreMaskingTaskDao.save(task);
String tablemappingkey = StringTool.getTablePrimaryKey();
TCoreMaskingTable sourcetable = new TCoreMaskingTable(task.getId(), datasystem.getId(), datamap.getDbschema(), maptable.getTablename(), tablemappingkey, EmaskingDirection.DATA_SOURCE.getFlag());
TCoreMaskingTable targettable = new TCoreMaskingTable(task.getId(), datatargetid, datatargetschema, targetTableName, tablemappingkey, EmaskingDirection.DATA_TARGET.getFlag());
this.tCoreMaskingTableDao.save(sourcetable);
this.tCoreMaskingTableDao.save(targettable);
Connection conn = this.getConnectionByDataSystemId(datasystem.getId());
for(ColumnInfo column : JdbcTool.getAllColumnInfo(conn, datamap.getDbschema(), maptable.getTablename())) {
String columnmappingkey = StringTool.getTablePrimaryKey();
TCoreMaskingTablecolumn sourcecolumn = new TCoreMaskingTablecolumn(task.getId(), sourcetable.getId(), columnmappingkey, EmaskingDirection.DATA_SOURCE.getFlag(), column.getColumnname(), (String)null, column.getColumnsize(), column.getColumnsize(), column.getDecimaldigits(), (String)null, column.getIsnullable(), 0, "", "", "");
TCoreMaskingTablecolumn targetcolumn = new TCoreMaskingTablecolumn(task.getId(), targettable.getId(), columnmappingkey, EmaskingDirection.DATA_TARGET.getFlag(), column.getColumnname(), (String)null, column.getColumnsize(), column.getColumnsize(), column.getDecimaldigits(), (String)null, column.getIsnullable(), 0, "", "", "");
this.tCoreMaskingTablecolumnDao.save(sourcecolumn);
this.tCoreMaskingTablecolumnDao.save(targetcolumn);
}
JdbcTool.closeConnection(conn);
return task;
}
}
package com.chenyang.nse.bussiness.service.info.db;
import com.power.xml.entity.ColumnInfo;
import java.sql.Connection;
import java.util.List;
import java.util.Map;
public interface DatabaseTool {
String ImportMethod();
String ExportMethod();
Map TargetParameter_normal();
Map TargetParameter_normal1();
Map TargetParameter_notNormal();
List<StringBuffer> SynTriggersParam(Connection s_conn, Map map);
List<StringBuffer> SynFunctionParam(Connection s_conn, Map map);
List<StringBuffer> SynProcedureParam(Connection s_conn, Map map);
ColumnInfo getPwc_columnInfo_target(Map map);
ColumnInfo getPwc_columnInfo_source(Map map);
List<StringBuffer> SynViewParam(Connection srcconn, Map map);
String SynConstraintParam(Connection srcconn, Map map);
String SynPartition(Connection s_conn, Map map);
Map TargetParameter_normalEM();
}
package com.chenyang.nse.bussiness.webtools.entity.vo;
public class DatabaseVO {
private String id;
private String fingerprint;
private String host;
private String schema;
private String port;
private String username;
private String password;
private String dbtype;
private String datasystemname;
private String plaintext;
private String desensitize;
public DatabaseVO(String id, String fingerprint, String host, String schema, String port, String username, String password, String dbtype, String datasystemname) {
this.id = id;
this.fingerprint = fingerprint;
this.host = host;
this.schema = schema;
this.port = port;
this.username = username;
this.password = password;
this.dbtype = dbtype;
this.datasystemname = datasystemname;
}
public String getId() {
return this.id;
}
public String getFingerprint() {
return this.fingerprint;
}
public String getHost() {
return this.host;
}
public String getSchema() {
return this.schema;
}
public String getPort() {
return this.port;
}
public String getUsername() {
return this.username;
}
public String getPassword() {
return this.password;
}
public String getDbtype() {
return this.dbtype;
}
public String getDatasystemname() {
return this.datasystemname;
}
public String getPlaintext() {
return this.plaintext;
}
public String getDesensitize() {
return this.desensitize;
}
public void setId(final String id) {
this.id = id;
}
public void setFingerprint(final String fingerprint) {
this.fingerprint = fingerprint;
}
public void setHost(final String host) {
this.host = host;
}
public void setSchema(final String schema) {
this.schema = schema;
}
public void setPort(final String port) {
this.port = port;
}
public void setUsername(final String username) {
this.username = username;
}
public void setPassword(final String password) {
this.password = password;
}
public void setDbtype(final String dbtype) {
this.dbtype = dbtype;
}
public void setDatasystemname(final String datasystemname) {
this.datasystemname = datasystemname;
}
public void setPlaintext(final String plaintext) {
this.plaintext = plaintext;
}
public void setDesensitize(final String desensitize) {
this.desensitize = desensitize;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
} else if (!(o instanceof DatabaseVO)) {
return false;
} else {
DatabaseVO other = (DatabaseVO)o;
if (!other.canEqual(this)) {
return false;
} else {
Object this$id = this.getId();
Object other$id = other.getId();
if (this$id == null) {
if (other$id != null) {
return false;
}
} else if (!this$id.equals(other$id)) {
return false;
}
Object this$fingerprint = this.getFingerprint();
Object other$fingerprint = other.getFingerprint();
if (this$fingerprint == null) {
if (other$fingerprint != null) {
return false;
}
} else if (!this$fingerprint.equals(other$fingerprint)) {
return false;
}
Object this$host = this.getHost();
Object other$host = other.getHost();
if (this$host == null) {
if (other$host != null) {
return false;
}
} else if (!this$host.equals(other$host)) {
return false;
}
Object this$schema = this.getSchema();
Object other$schema = other.getSchema();
if (this$schema == null) {
if (other$schema != null) {
return false;
}
} else if (!this$schema.equals(other$schema)) {
return false;
}
Object this$port = this.getPort();
Object other$port = other.getPort();
if (this$port == null) {
if (other$port != null) {
return false;
}
} else if (!this$port.equals(other$port)) {
return false;
}
Object this$username = this.getUsername();
Object other$username = other.getUsername();
if (this$username == null) {
if (other$username != null) {
return false;
}
} else if (!this$username.equals(other$username)) {
return false;
}
Object this$password = this.getPassword();
Object other$password = other.getPassword();
if (this$password == null) {
if (other$password != null) {
return false;
}
} else if (!this$password.equals(other$password)) {
return false;
}
Object this$dbtype = this.getDbtype();
Object other$dbtype = other.getDbtype();
if (this$dbtype == null) {
if (other$dbtype != null) {
return false;
}
} else if (!this$dbtype.equals(other$dbtype)) {
return false;
}
Object this$datasystemname = this.getDatasystemname();
Object other$datasystemname = other.getDatasystemname();
if (this$datasystemname == null) {
if (other$datasystemname != null) {
return false;
}
} else if (!this$datasystemname.equals(other$datasystemname)) {
return false;
}
Object this$plaintext = this.getPlaintext();
Object other$plaintext = other.getPlaintext();
if (this$plaintext == null) {
if (other$plaintext != null) {
return false;
}
} else if (!this$plaintext.equals(other$plaintext)) {
return false;
}
Object this$desensitize = this.getDesensitize();
Object other$desensitize = other.getDesensitize();
if (this$desensitize == null) {
if (other$desensitize != null) {
return false;
}
} else if (!this$desensitize.equals(other$desensitize)) {
return false;
}
return true;
}
}
}
protected boolean canEqual(final Object other) {
return other instanceof DatabaseVO;
}
public int hashCode() {
int PRIME = 59;
int result = 1;
Object $id = this.getId();
result = result * 59 + ($id == null ? 43 : $id.hashCode());
Object $fingerprint = this.getFingerprint();
result = result * 59 + ($fingerprint == null ? 43 : $fingerprint.hashCode());
Object $host = this.getHost();
result = result * 59 + ($host == null ? 43 : $host.hashCode());
Object $schema = this.getSchema();
result = result * 59 + ($schema == null ? 43 : $schema.hashCode());
Object $port = this.getPort();
result = result * 59 + ($port == null ? 43 : $port.hashCode());
Object $username = this.getUsername();
result = result * 59 + ($username == null ? 43 : $username.hashCode());
Object $password = this.getPassword();
result = result * 59 + ($password == null ? 43 : $password.hashCode());
Object $dbtype = this.getDbtype();
result = result * 59 + ($dbtype == null ? 43 : $dbtype.hashCode());
Object $datasystemname = this.getDatasystemname();
result = result * 59 + ($datasystemname == null ? 43 : $datasystemname.hashCode());
Object $plaintext = this.getPlaintext();
result = result * 59 + ($plaintext == null ? 43 : $plaintext.hashCode());
Object $desensitize = this.getDesensitize();
result = result * 59 + ($desensitize == null ? 43 : $desensitize.hashCode());
return result;
}
public String toString() {
return "DatabaseVO(id=" + this.getId() + ", fingerprint=" + this.getFingerprint() + ", host=" + this.getHost() + ", schema=" + this.getSchema() + ", port=" + this.getPort() + ", username=" + this.getUsername() + ", password=" + this.getPassword() + ", dbtype=" + this.getDbtype() + ", datasystemname=" + this.getDatasystemname() + ", plaintext=" + this.getPlaintext() + ", desensitize=" + this.getDesensitize() + ")";
}
}
<?xml version="1.0" encoding="UTF-8"?>
<sqls>
<select id="querySearchregexList">
SELECT
a.id,
a.createtime,
a.createuser,
a.dataarea,
b.flag,
b.icon,
b.id as ruleid,
b.`name`,
b.regex,
b.ruleexample,
b.ruleargument,
b.note,
b.defaulttype,
b.discoverway,
b.selectdatafield,
b.dictionaryClass,
b.matchingway,
b.remark
FROM
t_core_dataarea a left JOIN
t_console_searchregex b on
a.id = b.dataarea_id
where b.name is not null
and a.dataarea like :dataarea
and b.name like :rulename
ORDER BY b.dataarea_id,defaulttype desc
</select>
<select id="queryAllSearchregexCount">
SELECT
count(*)
FROM
t_core_dataarea a,
t_console_searchregex b
WHERE
a.tid = b.dataarea_id
and a.dataarea like :dataarea
and b.name like :rulename
</select>
<select id="querySearchregexById">
SELECT
a.id,
a.createtime,
a.createuser,
a.dataarea,
b.flag,
b.icon,
b.id as ruleid,
b.`name`,
b.regex,
b.ruleexample,
b.ruleargument,
b.note,
b.defaulttype,
b.discoverway,
b.selectdatafield,
b.dictionaryClass,
b.matchingway,
b.remark
FROM
t_core_dataarea a left JOIN
t_console_searchregex b on
a.id = b.dataarea_id
where b.id=:id
</select>
<select id="querySensitiveregexList">
SELECT
a.tid,
a.dataarea,
b.tid AS ruleid,
b.mappletname,
b.mappletname2,
b.mappletname3,
b.subjectarea,
b.subjectarea2,
b.subjectarea3,
b.ruledemo,
b.`name`,
b.note,
b.defaulttype
from t_core_dataarea a
LEFT JOIN t_core_masking_ruleinfo b
on a.tid=b.dataarea_id
where b.`name` is not null
and a.dataarea like :dataarea
and b.name like :rulename
ORDER BY b.dataarea_id
</select>
<select id="querySensitiveregexListnorulename">
SELECT
a.tid,
a.dataarea,
b.tid AS ruleid,
b.mappletname,
b.mappletname2,
b.mappletname3,
b.subjectarea,
b.subjectarea2,
b.subjectarea3,
b.ruledemo,
b.`name`,
b.note,
b.defaulttype,
b.defaultrule
from t_core_dataarea a
LEFT JOIN t_core_masking_ruleinfo b
on a.tid=b.dataarea_id
where
-- b.`name` is not null
1=1
and a.dataarea like :dataarea
ORDER BY a.areatype ASC ,a.createtime desc
</select>
<select id="queryAllSensitiveregexCount">
SELECT
count(*)
from t_core_dataarea a
LEFT JOIN t_core_masking_ruleinfo b
on a.tid=b.dataarea_id
where b.`name` is not null
and a.dataarea like :dataarea
and b.name like :rulename
</select>
<select id="queryRuleCount">
SELECT SUM(ROWNO) from(
(select count(*) ROWNO from t_console_searchregex a
where a.dataarea_id=:dataareaId)
union all
(select count(*) ROWNO from t_core_masking_ruleinfo b
where b.dataarea_id=:dataareaId))as c
</select>
<select id="querySearchregexbyprojectid">
SELECT
a.id,
a.createtime,
a.createuser,
a.dataarea,
b.flag,
b.icon,
b.id as ruleid,
b.`name`,
b.regex,
b.ruleexample,
b.ruleargument,
b.note,
b.defaulttype,
b.discoverway,
b.selectdatafield,
b.dictionaryClass,
b.matchingway,
b.remark
FROM
t_core_dataarea a left JOIN
t_console_searchregex b on
a.id = b.dataarea_id left JOIN
t_core_project_findrule c on
b.id = c.rule_id
where b.name is not null
and c.project_id =:projectid
ORDER BY b.dataarea_id
</select>
</sqls>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<sqls>
<!-- 查询数据地图表名列表 -->
<select id="queryUserMapTableName">
SELECT
maptable.tablename
FROM
t_core_datamap_usermap usermap
LEFT JOIN t_core_datamap_table maptable ON usermap.tableid = maptable.id
WHERE
usermap.datamapid = :datamapid
AND usermap.userid = :userid
</select>
<!-- 查询数据地图中私人订制地图中的数据系统id -->
<select id="queryUserMapDataSystemId">
SELECT DISTINCT
(datasystem.id) datasystemid
FROM
t_core_datamap_usermap usermap
LEFT JOIN t_core_datamap datamap ON usermap.datamapid = datamap.id
LEFT JOIN t_core_datasystem datasystem ON datamap.datasystemid = datasystem.id
WHERE
usermap.userid = :userid
</select>
<!-- 查询数据地图中私人订制地图制定数据系统下的schema列表 -->
<select id="queryUserMapSchema">
SELECT DISTINCT
(datamap.dbschema) schemaname
FROM
t_core_datamap_usermap usermap
LEFT JOIN t_core_datamap datamap ON usermap.datamapid = datamap.id
LEFT JOIN t_core_datasystem datasystem ON datamap.datasystemid = datasystem.id
WHERE
usermap.userid = :userid
AND datamap.datasystemid = :datasystemid
</select>
</sqls>
<?xml version="1.0" encoding="UTF-8"?>
<sql>
<select id="getDatamappingInfo">
select
info.id as id,
ds.id as sourcefieldid,
ds.fieldname as sourcefieldname,
info.flag as flag,
dt.id as targetfieldid,
dt.fieldname as targetfieldname,
info.targetlength as targetlength,
info.targetdecimal as targetdecimal,
info.note as note
from
t_console_datamapping_sourcefield ds left join t_console_datamapping_info info on
(
ds.id = info.sourcefieldid and info.targetsystemtype = :targetsystemtype
) left join t_console_datamapping_targetfield dt on
(
dt.id = info.targetfieldid
)
where
ds.datasystemtype = :sourcesystemtype
order by
ds.fieldname
</select>
</sql>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论