|
|
|
@ -5,7 +5,6 @@ import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
@ -13,7 +12,6 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import com.glxp.api.dao.idc.DbDao;
|
|
|
|
|
import com.glxp.api.idc.service.DeleteService;
|
|
|
|
|
import com.glxp.api.idc.utils.TableUtils;
|
|
|
|
|
import com.glxp.api.util.CustomUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -27,32 +25,15 @@ public class DeleteServiceImpl implements DeleteService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean syncDelete(String tableName,String uniqueValue) {
|
|
|
|
|
return syncDelete(tableName,"",uniqueValue);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public boolean syncDelete(String tableName,String uniqueColumn,String uniqueValue) {
|
|
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
|
|
map.put("tableName", tableName);
|
|
|
|
|
map.put("uniqueColumn", uniqueColumn);
|
|
|
|
|
map.put("uniqueValue", uniqueValue);
|
|
|
|
|
return syncDelete(map);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public boolean syncDelete(Map<String,Object> params) {
|
|
|
|
|
createTable();
|
|
|
|
|
String tableName = params.get("tableName").toString();
|
|
|
|
|
String uniqueColumn = params.get("uniqueColumn")!=null ? params.get("uniqueColumn").toString() : "";
|
|
|
|
|
if(StringUtils.isEmpty(uniqueColumn)) {
|
|
|
|
|
String[] syncTables = TableUtils.syncTables();
|
|
|
|
|
for(String str:syncTables) {
|
|
|
|
|
String[] tnames = str.split("/");
|
|
|
|
|
if(tnames[3].toLowerCase().equals(tableName.toLowerCase())) {
|
|
|
|
|
uniqueColumn = tnames[4];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String sql = "insert into idc_delete (id,tableName,uniqueColumn,updateTime,uniqueValue) values ('"+CustomUtil.getId()+"','"+params.get("tableName").toString().toLowerCase()+"','"+uniqueColumn+"',now(),'"+params.get("uniqueValue")+"')";
|
|
|
|
|
String sql = "insert into idc_delete (id,tableName,updateTime,uniqueValue) values ('"+CustomUtil.getId()+"','"+params.get("tableName").toString().toLowerCase()+"',now(),'"+params.get("uniqueValue")+"')";
|
|
|
|
|
|
|
|
|
|
if(dbDao.save(sql)>0)
|
|
|
|
|
return true;
|
|
|
|
@ -61,7 +42,7 @@ public class DeleteServiceImpl implements DeleteService {
|
|
|
|
|
|
|
|
|
|
private void createTable() {
|
|
|
|
|
try {
|
|
|
|
|
jdbcTemplate.execute("create table idc_delete (id varchar(36),tableName varchar(100),uniqueColumn varchar(60),uniqueValue varchar(600),updateTime datetime,PRIMARY KEY (id))");
|
|
|
|
|
jdbcTemplate.execute("create table idc_delete (id varchar(36),tableName varchar(100),uniqueValue varchar(600),updateTime datetime,PRIMARY KEY (id))");
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|