Commit 8ad5073b authored by 陈祥烨's avatar 陈祥烨

ip编辑和机构优化

parent 0b6b5dc1
......@@ -25,8 +25,6 @@ public class ApiSourceResource {
@Autowired
private ApiSourceService apiSourceService;
@Autowired
private ApiInfoService apiInfoService;
/**
* 新增
......
......@@ -13,6 +13,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import java.sql.SQLException;
import java.util.List;
......@@ -42,6 +43,22 @@ public class DataBaseLinkResource {
}
/**
* 根据sequenceNbr更新
*
* @param model 数据库连接
* @return DataBaseLinkModel
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
public ResponseModel<DataBaseLinkModel> updateBySeq(
@RequestBody DataBaseLinkModel model,
@PathVariable(value = "sequenceNbr") Long sequenceNbr) throws Exception {
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(dataBaseLinkService.update(model));
}
/**
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
......@@ -86,5 +103,19 @@ public class DataBaseLinkResource {
return ResponseHelper.buildResponse(dataBaseLinkService.queryForDataBaseList());
}
/**
* 列表分页查询
*
* @param request 请求
* @return Page<AgencyModel>
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/agency/list")
@ApiOperation(httpMethod = "GET", value = "机构列表查询", notes = "列表查询")
public ResponseModel<List<AgencyModel>> queryForList(HttpServletRequest request) throws SQLException {
return ResponseHelper.buildResponse(dataBaseLinkService.queryForAgencyList(request));
}
}
......@@ -3,16 +3,15 @@ package com.yeejoin.amos.api.tool.face.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.api.tool.face.model.AgencyModel;
import com.yeejoin.amos.api.tool.face.model.DataBaseLinkModel;
import com.yeejoin.amos.api.tool.face.model.TemplateModel;
import com.yeejoin.amos.api.tool.face.orm.dao.DataBaseLinkMapper;
import com.yeejoin.amos.api.tool.face.orm.entity.DataBaseLink;
import com.yeejoin.amos.api.tool.utils.AESUtils;
import com.yeejoin.amos.api.tool.utils.TableUtils;
import com.yeejoin.amos.api.tool.utils.DataBaseUtils;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import javax.servlet.http.HttpServletRequest;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
......@@ -40,12 +39,24 @@ public class DataBaseLinkService extends BaseService<DataBaseLinkModel, DataBase
}
/**
* 编辑
*/
public DataBaseLinkModel update(DataBaseLinkModel dataBaseLinkModel) throws Exception {
DataBaseLinkModel model = this.encryptPwd(dataBaseLinkModel);
if (this.testConnection(model)) {
return this.updateWithModel(model);
} else {
return new DataBaseLinkModel();
}
}
/**
* 机构分页查询
*/
public Page<AgencyModel> queryForAgencyPage(Page<AgencyModel> page, Long ipSeq) throws SQLException {
Connection connection = this.connectNewDatabase(this.queryBySeq(ipSeq));
List<Map<String, Object>> maps =
TableUtils.getMaps("SELECT AGENCY_NAME, AGENCY_CODE, AGENCY_DESC FROM privilege_agency;", connection);
DataBaseUtils.getMaps("SELECT AGENCY_NAME, AGENCY_CODE, AGENCY_DESC FROM privilege_agency;", connection);
connection.close();
List<AgencyModel> records = new ArrayList<>();
for (Map<String, Object> map : maps) {
......@@ -68,6 +79,26 @@ public class DataBaseLinkService extends BaseService<DataBaseLinkModel, DataBase
}
/**
* 机构列表查询
*/
public List<AgencyModel> queryForAgencyList(HttpServletRequest request) throws SQLException {
Connection connection = this.connectNewDatabase(this.queryModelByParams(request.getLocalAddr()));
List<Map<String, Object>> maps =
DataBaseUtils.getMaps("SELECT AGENCY_NAME, AGENCY_CODE, AGENCY_DESC FROM privilege_agency;", connection);
connection.close();
List<AgencyModel> records = new ArrayList<>();
for (Map<String, Object> map : maps) {
AgencyModel model = new AgencyModel();
model.setAgencyName(map.get("AGENCY_NAME").toString());
model.setAgencyCode(map.get("AGENCY_CODE").toString());
if ((map.get("AGENCY_DESC") != null))
model.setAgencyDesc(map.get("AGENCY_DESC").toString());
records.add(model);
}
return records;
}
/**
* 列表查询
*/
public List<DataBaseLinkModel> queryForDataBaseList() {
......@@ -128,4 +159,6 @@ public class DataBaseLinkService extends BaseService<DataBaseLinkModel, DataBase
return model;
}
}
package com.yeejoin.amos.api.tool.face.service;
import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.api.tool.enums.SourceEnum;
import com.yeejoin.amos.api.tool.face.model.DataBaseLinkModel;
import com.yeejoin.amos.api.tool.face.model.DataBaseNameListModel;
import com.yeejoin.amos.api.tool.face.model.RelationModel;
import com.yeejoin.amos.api.tool.face.model.RelationTreeModel;
import com.yeejoin.amos.api.tool.face.orm.dao.RelationMapper;
import com.yeejoin.amos.api.tool.face.orm.entity.DataBaseNameList;
import com.yeejoin.amos.api.tool.face.orm.entity.Relation;
import com.yeejoin.amos.api.tool.face.orm.entity.TableColumn;
import com.yeejoin.amos.api.tool.utils.TableUtils;
import com.yeejoin.amos.api.tool.utils.DataBaseUtils;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
......@@ -30,7 +25,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.yeejoin.amos.api.tool.utils.TableUtils.*;
import static com.yeejoin.amos.api.tool.utils.DataBaseUtils.*;
@Service
public class RelationService extends BaseService<RelationModel, Relation, RelationMapper> {
......@@ -222,11 +217,11 @@ public class RelationService extends BaseService<RelationModel, Relation, Relati
//根据列表获取sql语句
for (RelationTreeModel model : array) {
List<RelationTreeModel> tableSet = tableRelation(model, array);
List<TableColumn> columns = TableUtils.getTableColumn(model.getName(), connection);
List<TableColumn> columns = DataBaseUtils.getTableColumn(model.getName(), connection);
String sql = this.getSelectSQL(tableSet, model.getName(), columns, agencyCode).toString();
List<Map<String, Object>> dataList = TableUtils.getMaps(sql, connection);
List<Map<String, Object>> dataList = DataBaseUtils.getMaps(sql, connection);
System.out.println(sql);
StringBuffer insertSQL = TableUtils.getInsertSQL(dataList, columns, model.getName());
StringBuffer insertSQL = DataBaseUtils.getInsertSQL(dataList, columns, model.getName());
System.out.println(insertSQL);
if (!ObjectUtils.isEmpty(sql)) insertSql.append(insertSQL);
}
......
package com.yeejoin.amos.api.tool.face.service;
import com.yeejoin.amos.api.tool.face.orm.entity.TableColumn;
import com.yeejoin.amos.api.tool.utils.TableUtils;
import com.yeejoin.amos.api.tool.utils.DataBaseUtils;
import org.springframework.stereotype.Service;
import java.sql.Connection;
......@@ -31,12 +31,12 @@ public class TransferDataService {
public void transferData() throws SQLException, ClassNotFoundException {
Connection connection = this.connectDataBase(DBNAME_ORI);
List<Map<String,Object>> maps = TableUtils.getMaps("SELECT * FROM " + TABLE_ORI + " ;" , connection);
List<Map<String,Object>> maps = DataBaseUtils.getMaps("SELECT * FROM " + TABLE_ORI + " ;" , connection);
connection.close();
connection = this.connectDataBase(DBNAME_DES);
List<TableColumn> columns = TableUtils.getTableColumn(TABLE_DES,connection);
List<TableColumn> columns = DataBaseUtils.getTableColumn(TABLE_DES,connection);
List<Map<String,Object>> dataList = this.convertDataMap(maps, columns);
System.out.println(TableUtils.getInsertSQL(dataList,columns,TABLE_DES));
System.out.println(DataBaseUtils.getInsertSQL(dataList,columns,TABLE_DES));
}
public List<Map<String, Object>> convertDataMap(List<Map<String, Object>> maps, List<TableColumn> columns) {
......
......@@ -4,13 +4,14 @@ import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.api.tool.face.orm.entity.TableColumn;
import org.springframework.util.ObjectUtils;
import javax.servlet.http.HttpServletRequest;
import java.sql.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TableUtils {
public class DataBaseUtils {
/**
* 数据库备份路径
......@@ -91,7 +92,7 @@ public class TableUtils {
"\t\t\tAND table_name = \"" + tableName + "\"\n" +
"\t\tORDER BY\n" +
"\t\t\tordinal_position\t";
List<Map<String, Object>> columnList = TableUtils.getMaps(columnSql, connection);
List<Map<String, Object>> columnList = DataBaseUtils.getMaps(columnSql, connection);
List<TableColumn> columns = new ArrayList<>();
for (Map<String, Object> map : columnList) {
TableColumn column = JSON.parseObject(JSON.toJSONString(map), TableColumn.class);
......@@ -145,4 +146,6 @@ public class TableUtils {
}
return sql;
}
}
spring.application.name=AMOS-ATL
server.servlet.context-path=/atl
#server.servlet.context-path=/jcs
server.port=30201
#server.port=20000
#server.port=30201
server.port=20000
spring.profiles.active=dev
management.health.elasticsearch.enabled=false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment