fase()链路追踪
parent
f49fd448e5
commit
596dd3544f
|
@ -9,7 +9,6 @@ import org.springframework.context.annotation.Import;
|
|||
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规则引擎客户端配置类
|
||||
|
@ -18,7 +17,7 @@ import java.util.List;
|
|||
@ComponentScan
|
||||
@Import(value = AccessConfigRunner.class)
|
||||
public class AccessConfig {
|
||||
public List<DataModel> getRabdomData(Long id, String tableName,Integer ruleLevel) {
|
||||
public List<DataModel> getRabdomData(Long id, String tableName, Integer ruleLevel) {
|
||||
List<List<DataModel>> listList = new ArrayList<>();
|
||||
Connection connection = DataSourceConfig.getConnection(id);
|
||||
String sql = "select * from " + tableName;
|
||||
|
@ -27,27 +26,27 @@ public class AccessConfig {
|
|||
Statement statement = connection.createStatement();
|
||||
ResultSet resultSet = statement.executeQuery(sql);
|
||||
PreparedStatement pst = connection.prepareStatement("select * from " + tableName);
|
||||
log.info("元数据1:{}",resultSet);
|
||||
log.info("元数据1:{}", resultSet);
|
||||
// ResultSet resultSet1 = pst.executeQuery();
|
||||
//元数据信息
|
||||
ResultSetMetaData metaData = pst.getMetaData();
|
||||
//元数据数量
|
||||
int columnCount = metaData.getColumnCount();
|
||||
while (resultSet.next()){
|
||||
while (resultSet.next()) {
|
||||
List<DataModel> list = new ArrayList<>();
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
String columnName = metaData.getColumnName(i);
|
||||
log.info("字段名:{}",columnName);
|
||||
log.info("字段名:{}", columnName);
|
||||
String tableName1 = metaData.getTableName(i);
|
||||
log.info("表名:{}",tableName1);
|
||||
log.info("表名:{}", tableName1);
|
||||
String columnClassName = metaData.getColumnClassName(i);
|
||||
log.info("java类型:{}",columnClassName);
|
||||
log.info("java类型:{}", columnClassName);
|
||||
String columnTypeName = metaData.getColumnTypeName(i);
|
||||
log.info("原类型:{}",columnTypeName);
|
||||
log.info("原类型:{}", columnTypeName);
|
||||
String catalogName = metaData.getCatalogName(i);
|
||||
log.info("数据库名:{}",catalogName);
|
||||
log.info("数据库名:{}", catalogName);
|
||||
Object object = resultSet.getObject(i);
|
||||
log.info("字段值:{}",object);
|
||||
log.info("字段值:{}", object);
|
||||
DataModel build = DataModel.builder()
|
||||
.key(columnName)
|
||||
.val(object)
|
||||
|
@ -55,7 +54,7 @@ public class AccessConfig {
|
|||
.processType(columnClassName)
|
||||
.processClass(Class.forName(columnClassName))
|
||||
.build();
|
||||
log.info("测试内容:{}",build);
|
||||
log.info("测试内容:{}", build);
|
||||
list.add(build);
|
||||
}
|
||||
listList.add(list);
|
||||
|
@ -65,9 +64,9 @@ public class AccessConfig {
|
|||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
log.info("长度:{}",listList.size());
|
||||
log.info("列表:{}",listList);
|
||||
if (listList.size() == 0){
|
||||
log.info("长度:{}", listList.size());
|
||||
log.info("列表:{}", listList);
|
||||
if (listList.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
for (List<DataModel> list : listList) {
|
||||
|
@ -87,12 +86,12 @@ public class AccessConfig {
|
|||
Statement statement = connection.createStatement();
|
||||
ResultSet resultSet = statement.executeQuery(sql);
|
||||
PreparedStatement pst = connection.prepareStatement("select * from " + tableName);
|
||||
log.info("元数据1:{}",resultSet);
|
||||
log.info("元数据1:{}", resultSet);
|
||||
//元数据信息
|
||||
ResultSetMetaData metaData = pst.getMetaData();
|
||||
//元数据数量
|
||||
int columnCount = metaData.getColumnCount();
|
||||
while (resultSet.next()){
|
||||
while (resultSet.next()) {
|
||||
List<DataModel> list = new ArrayList<>();
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
String columnName = metaData.getColumnName(i);
|
||||
|
@ -118,6 +117,7 @@ public class AccessConfig {
|
|||
}
|
||||
return listList;
|
||||
}
|
||||
|
||||
private Map<String, String> getColumnComments(DatabaseMetaData metaData, String typeName) {
|
||||
Map<String, String> columnComents = new HashMap<>();
|
||||
try (ResultSet colums = metaData.getColumns(null, null, typeName, null)) {
|
||||
|
|
|
@ -2,12 +2,8 @@ package muyu.data.test.clinet.config;
|
|||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.exception.ServiceException;
|
||||
import com.muyu.edition.constant.RuleOperationConstants;
|
||||
import com.muyu.edition.domain.Config;
|
||||
import com.muyu.edition.domain.Edition;
|
||||
import com.muyu.edition.domain.RuleEngine;
|
||||
import com.muyu.goods.edition.remote.EditionDataRemoteService;
|
||||
import com.muyu.goods.edition.remote.RemoteDataManagerService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import muyu.data.test.clinet.config.runner.DataEditionConfigRunner;
|
||||
import muyu.data.test.common.context.DataModelContextHolder;
|
||||
|
@ -37,8 +33,9 @@ import java.util.stream.Collectors;
|
|||
public class DataEditionConfig {
|
||||
@Autowired
|
||||
private EditionDataRemoteService editionDataRemoteService;
|
||||
|
||||
public Object setColumn(TestDataModelReq testDataModelReq) {
|
||||
switch (testDataModelReq.getRuleLevel()){
|
||||
switch (testDataModelReq.getRuleLevel()) {
|
||||
case 2:
|
||||
//先获取一个记录列
|
||||
List<RecordModel> dataModels = new ArrayList<>();
|
||||
|
@ -90,7 +87,7 @@ public class DataEditionConfig {
|
|||
mainMethod.invoke(o);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("异常"+e.getMessage());
|
||||
throw new ServiceException("异常" + e.getMessage());
|
||||
}
|
||||
return "正常,无需返回";
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.springframework.boot.ApplicationRunner;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -31,7 +30,7 @@ public class AccessConfigRunner implements ApplicationRunner {
|
|||
Result<List<DataAccess>> lists = remoteSystemManageService.lists();
|
||||
// log.info("数据源调用状态:{}",lists);
|
||||
//判断非空
|
||||
if (lists.getData() == null || lists.getData().isEmpty()){
|
||||
if (lists.getData() == null || lists.getData().isEmpty()) {
|
||||
log.error("数据为空");
|
||||
return;
|
||||
}
|
||||
|
@ -43,11 +42,11 @@ public class AccessConfigRunner implements ApplicationRunner {
|
|||
HashMap<Long, DataAccess> frimaryVoHashMap = new HashMap<>();
|
||||
//遍历循环存入map
|
||||
listResultData.forEach(res -> {
|
||||
frimaryVoHashMap.put(res.getId(),res);
|
||||
frimaryVoHashMap.put(res.getId(), res);
|
||||
});
|
||||
//遍历添加到hashMap
|
||||
for (DataAccess listResultDatum : listResultData) {
|
||||
if (listResultDatum.getType().equals("MySql")){
|
||||
if (listResultDatum.getType().equals("MySql")) {
|
||||
//记录线程池
|
||||
DataSourceConfig.index(listResultDatum);
|
||||
}
|
||||
|
@ -55,7 +54,4 @@ public class AccessConfigRunner implements ApplicationRunner {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.stream.Collectors;
|
|||
@Log4j2
|
||||
@Component
|
||||
@Configuration
|
||||
public class DataEditionConfigRunner implements ApplicationRunner , ApplicationContextAware {
|
||||
public class DataEditionConfigRunner implements ApplicationRunner, ApplicationContextAware {
|
||||
@Autowired
|
||||
private RemoteDataManagerService remoteDataManagerService;
|
||||
@Autowired
|
||||
|
@ -32,6 +32,7 @@ public class DataEditionConfigRunner implements ApplicationRunner , ApplicationC
|
|||
|
||||
/**
|
||||
* 根据环境变量来决定是否执行
|
||||
*
|
||||
* @param applicationContext the ApplicationContext object to be used by this object
|
||||
* @throws BeansException
|
||||
*/
|
||||
|
@ -39,6 +40,7 @@ public class DataEditionConfigRunner implements ApplicationRunner , ApplicationC
|
|||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
System.out.println("1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
//获取引擎
|
||||
|
@ -55,7 +57,7 @@ public class DataEditionConfigRunner implements ApplicationRunner , ApplicationC
|
|||
List<Edition> editions = editionList.stream().filter(e -> e.getRuleId().equals(listResultDatum.getRuleId())).collect(Collectors.toList());
|
||||
EditionSoutceConfig.indexByte(editions);
|
||||
for (Edition edition : editionList.stream().filter(e -> e.getRuleId().equals(listResultDatum.getRuleId())).collect(Collectors.toList())) {
|
||||
EditionSoutceConfig.index(listResultDatum.getRuleId(),edition);
|
||||
EditionSoutceConfig.index(listResultDatum.getRuleId(), edition);
|
||||
}
|
||||
}
|
||||
Long ruleId = listResultData.get(0).getRuleId();
|
||||
|
@ -65,8 +67,8 @@ public class DataEditionConfigRunner implements ApplicationRunner , ApplicationC
|
|||
|
||||
HashMap<Long, Map<String, byte[]>> even = EditionSoutceConfig.even();
|
||||
Map<String, byte[]> aByte = EditionSoutceConfig.getByte(id);
|
||||
log.info("总表:{}",even);
|
||||
log.info("第一个:{}",aByte);
|
||||
log.info("总表:{}", even);
|
||||
log.info("第一个:{}", aByte);
|
||||
String versionClass = editionList.get(0).getVersionClass();
|
||||
byte[] bytes = aByte.get(versionClass);
|
||||
String s = new String(bytes);
|
||||
|
|
|
@ -7,18 +7,19 @@ import muyu.data.test.common.model.process.DataModelProcessModel;
|
|||
|
||||
/**
|
||||
* 数据模型上下文
|
||||
*
|
||||
* @ClassName DataModelContextHolder
|
||||
* @Author 森静若林
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class DataModelContextHolder{
|
||||
public class DataModelContextHolder {
|
||||
|
||||
private static final ThreadLocal<DataModelProcessModel> THREAD_LOCAL=new ThreadLocal<>();
|
||||
private static final ThreadLocal<DataModelProcessModel> THREAD_LOCAL = new ThreadLocal<>();
|
||||
|
||||
private RecordContextHolder recordContextHolder;
|
||||
|
||||
public static DataModelContextHolder build(RecordContextHolder recordContextHolder){
|
||||
public static DataModelContextHolder build(RecordContextHolder recordContextHolder) {
|
||||
return DataModelContextHolder.builder()
|
||||
.recordContextHolder(recordContextHolder)
|
||||
.build();
|
||||
|
|
|
@ -6,18 +6,19 @@ import muyu.data.test.common.model.process.DataSetProcessModel;
|
|||
|
||||
/**
|
||||
* 数据集上下文
|
||||
*
|
||||
* @ClassName DataSetContextHolder
|
||||
* @Author 森静若林
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class DataSetContextHolder{
|
||||
public class DataSetContextHolder {
|
||||
|
||||
private static final ThreadLocal<DataSetProcessModel> THREAD_LOCAL=new ThreadLocal<>();
|
||||
private static final ThreadLocal<DataSetProcessModel> THREAD_LOCAL = new ThreadLocal<>();
|
||||
|
||||
private TaskContextHolder taskContextHolder;
|
||||
|
||||
public static DataSetContextHolder build(TaskContextHolder taskContextHolder){
|
||||
public static DataSetContextHolder build(TaskContextHolder taskContextHolder) {
|
||||
return DataSetContextHolder.builder()
|
||||
.taskContextHolder(taskContextHolder)
|
||||
.build();
|
||||
|
|
|
@ -6,18 +6,19 @@ import muyu.data.test.common.model.process.RecordProcessModel;
|
|||
|
||||
/**
|
||||
* 记录上下文
|
||||
*
|
||||
* @ClassName RecordContextHolder
|
||||
* @Author 森静若林
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class RecordContextHolder{
|
||||
public class RecordContextHolder {
|
||||
|
||||
private static final ThreadLocal<RecordProcessModel> THREAD_LOCAL=new ThreadLocal<>();
|
||||
private static final ThreadLocal<RecordProcessModel> THREAD_LOCAL = new ThreadLocal<>();
|
||||
|
||||
private DataSetContextHolder dataSetContextHolder;
|
||||
|
||||
public static RecordContextHolder build(DataSetContextHolder dataSetContextHolder){
|
||||
public static RecordContextHolder build(DataSetContextHolder dataSetContextHolder) {
|
||||
return RecordContextHolder.builder()
|
||||
.dataSetContextHolder(dataSetContextHolder)
|
||||
.build();
|
||||
|
|
|
@ -2,12 +2,13 @@ package muyu.data.test.common.context;
|
|||
|
||||
/**
|
||||
* 任务上下文
|
||||
*
|
||||
* @ClassName TaskContextHolder
|
||||
* @Author 森静若林
|
||||
*/
|
||||
public class TaskContextHolder {
|
||||
|
||||
public static TaskContextHolder build(){
|
||||
public static TaskContextHolder build() {
|
||||
return new TaskContextHolder();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,8 @@ import java.util.HashMap;
|
|||
@Log4j2
|
||||
public class DataSourceConfig {
|
||||
|
||||
private static HashMap<Long,DruidDataSource> hashMap = new HashMap<>();
|
||||
private static HashMap<Long, DruidDataSource> hashMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 添加线程池
|
||||
* 线程池初始化
|
||||
|
@ -34,7 +35,7 @@ public class DataSourceConfig {
|
|||
//数据库名
|
||||
String databaseName = dataAccess.getDatabaseName();
|
||||
// url
|
||||
String url = String.format("jdbc:mysql://"+ host+":"+port+"/"+databaseName);
|
||||
String url = String.format("jdbc:mysql://" + host + ":" + port + "/" + databaseName);
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
//初始化链接池数量
|
||||
dataSource.setInitialSize(dataAccess.getInitNum().intValue());
|
||||
|
@ -51,14 +52,14 @@ public class DataSourceConfig {
|
|||
//数据库密码
|
||||
dataSource.setPassword(dataAccess.getPassword());
|
||||
dataSource.init();// 初始化
|
||||
hashMap.put(dataAccess.getId(),dataSource);
|
||||
hashMap.put(dataAccess.getId(), dataSource);
|
||||
// log.info("储存线程池:{}",hashMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取出线程池
|
||||
*/
|
||||
public static Connection getConnection(Long key){
|
||||
public static Connection getConnection(Long key) {
|
||||
DruidDataSource dataSource = hashMap.get(key);
|
||||
try {
|
||||
DruidPooledConnection connection = dataSource.getConnection();
|
||||
|
@ -67,16 +68,18 @@ public class DataSourceConfig {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 归还线程池
|
||||
*/
|
||||
public static void returnConnection(Connection connection){
|
||||
public static void returnConnection(Connection connection) {
|
||||
try {
|
||||
connection.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 连接线程池
|
||||
* 验证线程池
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
package muyu.data.test.common.dataSoutce;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.muyu.edition.constant.RuleOperationConstants;
|
||||
import com.muyu.edition.domain.Edition;
|
||||
import com.muyu.edition.domain.RuleEngine;
|
||||
import lombok.Data;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import muyu.data.test.common.dymamicLoad.DynamicLoader;
|
||||
import org.bouncycastle.pqc.crypto.newhope.NHSecretKeyProcessor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -23,31 +20,31 @@ public class EditionSoutceConfig {
|
|||
private static HashMap<Long, HashMap<Long, Edition>> hashMap = new HashMap<>();
|
||||
private static HashMap<Long, Map<String, byte[]>> longHashMapHashMap = new HashMap<>();
|
||||
|
||||
public static void index(Long ruleId, Edition edition){
|
||||
public static void index(Long ruleId, Edition edition) {
|
||||
HashMap<Long, Edition> editionHashMap = new HashMap<>();
|
||||
editionHashMap.put(edition.getId(),edition);
|
||||
hashMap.put(ruleId,editionHashMap);
|
||||
editionHashMap.put(edition.getId(), edition);
|
||||
hashMap.put(ruleId, editionHashMap);
|
||||
}
|
||||
|
||||
public static void indexByte(List<Edition> list){
|
||||
public static void indexByte(List<Edition> list) {
|
||||
list.stream().forEach(engine -> {
|
||||
//获取版本内容
|
||||
String content = engine.getRuleContent().replaceAll("\r\n", "");
|
||||
//编译生成class文件存放到Map中
|
||||
Map<String, byte[]> compile = DynamicLoader.compile( engine.getVersionClass() + RuleOperationConstants.FILE_SUFFIX, content);
|
||||
longHashMapHashMap.put(engine.getId(),compile);
|
||||
Map<String, byte[]> compile = DynamicLoader.compile(engine.getVersionClass() + RuleOperationConstants.FILE_SUFFIX, content);
|
||||
longHashMapHashMap.put(engine.getId(), compile);
|
||||
});
|
||||
}
|
||||
|
||||
public static HashMap<Long,Edition> get(Long ruleId){
|
||||
public static HashMap<Long, Edition> get(Long ruleId) {
|
||||
return hashMap.get(ruleId);
|
||||
}
|
||||
|
||||
public static Map<String,byte[]> getByte(Long id){
|
||||
public static Map<String, byte[]> getByte(Long id) {
|
||||
return longHashMapHashMap.get(id);
|
||||
}
|
||||
|
||||
public static HashMap<Long , Map<String, byte[]>> even(){
|
||||
public static HashMap<Long, Map<String, byte[]>> even() {
|
||||
return longHashMapHashMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package muyu.data.test.common.domain.model;
|
||||
|
||||
import com.alibaba.nacos.api.annotation.NacosProperties;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
|
|
@ -2,6 +2,7 @@ package muyu.data.test.common.engine;
|
|||
|
||||
/**
|
||||
* 引擎
|
||||
*
|
||||
* @ClassName Engine
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/5/6 13:48
|
||||
|
|
|
@ -6,6 +6,7 @@ import lombok.extern.log4j.Log4j2;
|
|||
|
||||
/**
|
||||
* 记录动作
|
||||
*
|
||||
* @ClassName ActionRecords
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/13 22:31
|
||||
|
@ -13,11 +14,11 @@ import lombok.extern.log4j.Log4j2;
|
|||
@Getter
|
||||
@Setter
|
||||
@Log4j2
|
||||
public class ActionRecords extends RuntimeException{
|
||||
public class ActionRecords extends RuntimeException {
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name="记录";
|
||||
private String name = "记录";
|
||||
|
||||
/**
|
||||
* 数据模型
|
||||
|
@ -28,7 +29,7 @@ public class ActionRecords extends RuntimeException{
|
|||
this.object = object;
|
||||
}
|
||||
|
||||
public void records(){
|
||||
log.info("记录的数据是:{}",this.object);
|
||||
public void records() {
|
||||
log.info("记录的数据是:{}", this.object);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,17 +6,18 @@ import lombok.Setter;
|
|||
|
||||
/**
|
||||
* 移除动作
|
||||
*
|
||||
* @ClassName ActionRemove
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class ActionRemove extends RuntimeException{
|
||||
public class ActionRemove extends RuntimeException {
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name="移除";
|
||||
private String name = "移除";
|
||||
/**
|
||||
* 数据模型
|
||||
*/
|
||||
|
@ -26,7 +27,7 @@ public class ActionRemove extends RuntimeException{
|
|||
this.dataModel = dataModel;
|
||||
}
|
||||
|
||||
public void remove(){
|
||||
public void remove() {
|
||||
this.dataModel.setValue(null);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,17 +6,18 @@ import lombok.Setter;
|
|||
|
||||
/**
|
||||
* 替换动作
|
||||
*
|
||||
* @ClassName ActionReplace
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ActionReplace extends RuntimeException{
|
||||
public class ActionReplace extends RuntimeException {
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name="替换";
|
||||
private String name = "替换";
|
||||
/**
|
||||
* 新值
|
||||
*/
|
||||
|
@ -26,7 +27,7 @@ public class ActionReplace extends RuntimeException{
|
|||
*/
|
||||
private DataModel dataModel;
|
||||
|
||||
public ActionReplace(String newValue,DataModel dataModel) {
|
||||
public ActionReplace(String newValue, DataModel dataModel) {
|
||||
super();
|
||||
this.newValue = newValue;
|
||||
this.dataModel = dataModel;
|
||||
|
@ -36,7 +37,7 @@ public class ActionReplace extends RuntimeException{
|
|||
super();
|
||||
}
|
||||
|
||||
public void replace(){
|
||||
public void replace() {
|
||||
this.dataModel.setValue(this.newValue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package muyu.data.test.common.engine.scope;
|
||||
|
||||
|
||||
|
||||
import muyu.data.test.common.context.DataModelContextHolder;
|
||||
import muyu.data.test.common.engine.Engine;
|
||||
import muyu.data.test.common.model.DataModel;
|
||||
|
@ -9,6 +8,7 @@ import muyu.data.test.common.model.process.DataModelProcessModel;
|
|||
|
||||
/**
|
||||
* 数据模型引擎
|
||||
*
|
||||
* @ClassName DataModelEngine
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/5/6 13:48
|
||||
|
@ -16,32 +16,32 @@ import muyu.data.test.common.model.process.DataModelProcessModel;
|
|||
public abstract class DataModelEngine implements Engine<DataModelProcessModel> {
|
||||
|
||||
@Override
|
||||
public DataModelProcessModel get (){
|
||||
public DataModelProcessModel get() {
|
||||
return DataModelContextHolder.get();
|
||||
}
|
||||
|
||||
public DataModel getModel(){
|
||||
public DataModel getModel() {
|
||||
return get().getDataModel();
|
||||
}
|
||||
|
||||
|
||||
public String getKey () {
|
||||
public String getKey() {
|
||||
return getModel().getKey();
|
||||
}
|
||||
|
||||
public Object getValue () {
|
||||
public Object getValue() {
|
||||
return getModel().getVal();
|
||||
}
|
||||
|
||||
public String getSourceType () {
|
||||
public String getSourceType() {
|
||||
return getModel().getSourceType();
|
||||
}
|
||||
|
||||
public String getProcessType () {
|
||||
public String getProcessType() {
|
||||
return getModel().getProcessType();
|
||||
}
|
||||
|
||||
public Class<?> getProcessClass () {
|
||||
public Class<?> getProcessClass() {
|
||||
return getModel().getProcessClass();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 数据集引擎
|
||||
*
|
||||
* @ClassName DataSetEngine
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/5/6 13:48
|
||||
|
@ -17,15 +18,15 @@ import java.util.List;
|
|||
public abstract class DataSetEngine implements Engine<DataSetProcessModel> {
|
||||
|
||||
@Override
|
||||
public DataSetProcessModel get (){
|
||||
public DataSetProcessModel get() {
|
||||
return DataSetContextHolder.get();
|
||||
}
|
||||
|
||||
public DataSetModel getModel(){
|
||||
public DataSetModel getModel() {
|
||||
return get().getDataSetModel();
|
||||
}
|
||||
|
||||
public List<RecordModel> getRecordModels () {
|
||||
public List<RecordModel> getRecordModels() {
|
||||
return getModel().getRecordModels();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package muyu.data.test.common.engine.scope;
|
||||
|
||||
|
||||
|
||||
import muyu.data.test.common.context.RecordContextHolder;
|
||||
import muyu.data.test.common.engine.Engine;
|
||||
import muyu.data.test.common.model.DataModel;
|
||||
|
@ -12,6 +11,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 记录引擎
|
||||
*
|
||||
* @ClassName RecordEngine
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/5/6 13:48
|
||||
|
@ -19,19 +19,19 @@ import java.util.List;
|
|||
public abstract class RecordEngine implements Engine<RecordProcessModel> {
|
||||
|
||||
@Override
|
||||
public RecordProcessModel get (){
|
||||
public RecordProcessModel get() {
|
||||
return RecordContextHolder.get();
|
||||
}
|
||||
|
||||
public List<String> getKeys(){
|
||||
public List<String> getKeys() {
|
||||
return get().getKeys();
|
||||
}
|
||||
|
||||
public RecordModel getModel(){
|
||||
public RecordModel getModel() {
|
||||
return get().getRecordModel();
|
||||
}
|
||||
|
||||
public List<DataModel> getDataModels () {
|
||||
public List<DataModel> getDataModels() {
|
||||
return getModel().getDataModels();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import lombok.experimental.SuperBuilder;
|
|||
|
||||
/**
|
||||
* 数据模型
|
||||
*
|
||||
* @ClassName DataModel
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/5 18:48
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 数据集模型
|
||||
*
|
||||
* @ClassName DataSetModel
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/5 18:48
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 记录模型
|
||||
*
|
||||
* @ClassName RecordModel
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/5 18:48
|
||||
|
|
|
@ -7,6 +7,7 @@ import muyu.data.test.common.model.DataModel;
|
|||
|
||||
/**
|
||||
* 数据模型处理模型
|
||||
*
|
||||
* @ClassName DataModelProcessModel
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/5 18:37
|
||||
|
|
|
@ -7,6 +7,7 @@ import muyu.data.test.common.model.DataSetModel;
|
|||
|
||||
/**
|
||||
* 数据集处理模型
|
||||
*
|
||||
* @ClassName DataSetProcessModel
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/5 18:37
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 记录处理模型
|
||||
*
|
||||
* @ClassName RecordProcessModel
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/5 18:37
|
||||
|
|
|
@ -5,7 +5,6 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import muyu.data.test.common.model.DataModel;
|
||||
import org.w3c.dom.stylesheets.LinkStyle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.muyu.common.security.annotation.EnableMyFeignClients;
|
|||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
@SpringBootApplication
|
||||
|
@ -15,6 +14,6 @@ import org.springframework.scheduling.annotation.EnableAsync;
|
|||
@EnableAsync
|
||||
public class DataTestApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DataTestApplication.class,args);
|
||||
SpringApplication.run(DataTestApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,12 +5,11 @@ import com.muyu.common.core.domain.Result;
|
|||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import muyu.data.test.common.model.DataModel;
|
||||
import muyu.data.test.common.model.DataModel;
|
||||
import muyu.data.test.common.req.TestDataModelReq;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.sql.*;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
@Log4j2
|
||||
|
@ -19,18 +18,21 @@ import java.util.List;
|
|||
public class TestController extends BaseController {
|
||||
@Autowired
|
||||
private TestService service;
|
||||
|
||||
/**
|
||||
* 随机字段
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("getRabdomData")
|
||||
public Result<List<DataModel>> getRabdomData(Long id, String tableName,Integer ruleLevel) throws SQLException {
|
||||
return success(service.getRabdomData(id,tableName,ruleLevel));
|
||||
public Result<List<DataModel>> getRabdomData(Long id, String tableName, Integer ruleLevel) throws SQLException {
|
||||
return success(service.getRabdomData(id, tableName, ruleLevel));
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示队列
|
||||
*
|
||||
* @param id
|
||||
* @param tableName
|
||||
* @param ruleLevel
|
||||
|
@ -39,16 +41,16 @@ public class TestController extends BaseController {
|
|||
*/
|
||||
@GetMapping("getColumn")
|
||||
public Result<List<List<DataModel>>> getColumn(Long id, String tableName, Integer ruleLevel) throws Exception {
|
||||
return success(service.getColumn(id,tableName,ruleLevel));
|
||||
return success(service.getColumn(id, tableName, ruleLevel));
|
||||
}
|
||||
|
||||
@PostMapping("setColumn")
|
||||
public Result setColumn(@RequestBody TestDataModelReq testDataModelReq){
|
||||
public Result setColumn(@RequestBody TestDataModelReq testDataModelReq) {
|
||||
return success(service.setColumn(testDataModelReq));
|
||||
}
|
||||
|
||||
@PostMapping("editionInitialize")
|
||||
public void editionInitialize(){
|
||||
public void editionInitialize() {
|
||||
service.editionInitialize();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,19 +10,20 @@ import org.springframework.stereotype.Component;
|
|||
@Component
|
||||
@Log4j2
|
||||
public class Consumer {
|
||||
@Autowired
|
||||
private TestController testController;
|
||||
//队列名称
|
||||
public static final String QueueName = "edition";
|
||||
@Autowired
|
||||
private TestController testController;
|
||||
|
||||
/**
|
||||
* 监听队列
|
||||
*/
|
||||
@RabbitListener(queuesToDeclare = {@Queue("edition")})
|
||||
public void testEdition(Integer id){
|
||||
if (id>0){
|
||||
public void testEdition(Integer id) {
|
||||
if (id > 0) {
|
||||
testController.editionInitialize();
|
||||
log.info("初始化");
|
||||
}else{
|
||||
} else {
|
||||
log.info("等待");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.data.test.server;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import muyu.data.test.common.model.DataModel;
|
||||
import muyu.data.test.common.req.TestDataModelReq;
|
||||
|
||||
|
@ -8,7 +7,7 @@ import java.sql.SQLException;
|
|||
import java.util.List;
|
||||
|
||||
public interface TestService {
|
||||
List<DataModel> getRabdomData(Long id, String tableName,Integer ruleLevel) throws SQLException;
|
||||
List<DataModel> getRabdomData(Long id, String tableName, Integer ruleLevel) throws SQLException;
|
||||
|
||||
List<List<DataModel>> getColumn(Long id, String tableName, Integer ruleLevel);
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.data.test.server.impl;
|
||||
|
||||
import com.data.test.server.TestService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import muyu.data.test.clinet.config.AccessConfig;
|
||||
import muyu.data.test.clinet.config.DataEditionConfig;
|
||||
import muyu.data.test.common.model.DataModel;
|
||||
|
@ -18,14 +17,15 @@ public class TestServiceImpl implements TestService {
|
|||
private AccessConfig accessConfig;
|
||||
@Autowired
|
||||
private DataEditionConfig dataEditionConfig;
|
||||
|
||||
@Override
|
||||
public List<DataModel> getRabdomData(Long id, String tableName, Integer ruleLevel) throws SQLException {
|
||||
return accessConfig.getRabdomData(id,tableName,ruleLevel);
|
||||
return accessConfig.getRabdomData(id, tableName, ruleLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<List<DataModel>> getColumn(Long id, String tableName, Integer ruleLevel) {
|
||||
return accessConfig.getColumn(id,tableName,ruleLevel);
|
||||
return accessConfig.getColumn(id, tableName, ruleLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,5 +29,14 @@
|
|||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package com.muyu.edition.DCL;
|
||||
|
||||
import org.slf4j.MDC;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MDCTraceUtil {
|
||||
/**
|
||||
* 追踪id的名称
|
||||
*/
|
||||
public static final String KEY_TRACE_ID = "traceId";
|
||||
|
||||
/**
|
||||
* 日志链路追踪id信息头
|
||||
*/
|
||||
public static final String TRACE_ID_HEADER = "x-traceId-header";
|
||||
|
||||
|
||||
/**
|
||||
* 创建traceId并赋值MDC
|
||||
*/
|
||||
public static void addTrace() {
|
||||
String traceId = createTraceId();
|
||||
// MDC(Mapped Diagnostic Context)诊断上下文映射,是@Slf4j提供的一个支持动态打印日志信息的工具。
|
||||
MDC.put(KEY_TRACE_ID, traceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 赋值MDC
|
||||
*/
|
||||
public static void putTrace(String traceId) {
|
||||
MDC.put(KEY_TRACE_ID, traceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取MDC中的traceId值
|
||||
*/
|
||||
public static String getTraceId() {
|
||||
return MDC.get(KEY_TRACE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除MDC的值
|
||||
*/
|
||||
public static void removeTrace() {
|
||||
MDC.remove(KEY_TRACE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建traceId
|
||||
*/
|
||||
public static String createTraceId() {
|
||||
return UUID.randomUUID().toString().replace("-", "");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.muyu.edition.config;
|
||||
|
||||
import com.muyu.edition.config.LogInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
|
||||
@Configuration
|
||||
public class LogWebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// 添加拦截器
|
||||
registry.addInterceptor(mvcInterceptor())
|
||||
// 拦截所有请求的路径
|
||||
.addPathPatterns("/**");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LogInterceptor mvcInterceptor() {
|
||||
return new LogInterceptor();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.muyu.edition.config;
|
||||
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import com.muyu.edition.DCL.MDCTraceUtil;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
public class LogInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
// 客户端可以传入链路ID,需要唯一性
|
||||
String traceId = request.getHeader(MDCTraceUtil.TRACE_ID_HEADER);
|
||||
if (!StringUtils.isEmpty(traceId)) {
|
||||
MDCTraceUtil.putTrace(request.getHeader(MDCTraceUtil.TRACE_ID_HEADER));
|
||||
} else {
|
||||
MDCTraceUtil.addTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||
MDCTraceUtil.removeTrace();
|
||||
}
|
||||
}
|
|
@ -31,3 +31,4 @@ spring:
|
|||
logging:
|
||||
level:
|
||||
com.muyu.edition.mapper: DEBUG
|
||||
config: classpath:logback-spring.xml
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
|
||||
<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true -->
|
||||
<!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
|
||||
<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
|
||||
<configuration scan="true" scanPeriod="10 seconds">
|
||||
<contextName>logback</contextName>
|
||||
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
|
||||
<springProperty scope="context" name="log.path" source="log.path"/>
|
||||
<!-- 彩色日志 -->
|
||||
<!-- 彩色日志依赖的渲染类 -->
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
|
||||
<conversionRule conversionWord="wex"
|
||||
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
|
||||
<conversionRule conversionWord="wEx"
|
||||
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
|
||||
<!-- 彩色日志格式 -->
|
||||
<property name="CONSOLE_LOG_PATTERN"
|
||||
value="[traceId:%X{traceId}] ${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||
|
||||
<property name="PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"/>
|
||||
<!--输出到控制台-->
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>debug</level>
|
||||
</filter>
|
||||
<encoder>
|
||||
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
|
||||
<!-- 设置字符集 -->
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
<!-- 滚动文件输出日志 -->
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/log.log</file>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 每天日志归档路径以及格式 -->
|
||||
<fileNamePattern>${log.path}/log-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>10MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<!--日志文件保留天数-->
|
||||
<maxHistory>15</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<!-- 配置日志输出的方式,可以同时输出到控制台和文件 -->
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
</root>
|
||||
</configuration>
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Stream {
|
||||
private String name;
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<String> list = Arrays.asList("dsf", "psd", "qw3", "dfq332", "dgw4thn","dps","dps");
|
||||
//遍历转换成大写
|
||||
List<String> collect1 = list.stream().map(String::toUpperCase).collect(Collectors.toList());
|
||||
System.out.println(collect1);
|
||||
//过滤
|
||||
List<String> collect2 = list.stream().filter(e -> !e.contains("d")).collect(Collectors.toList());
|
||||
System.out.println(collect2);
|
||||
// 10个随机数
|
||||
Random random = new Random();
|
||||
// random.ints().limit(3).forEach(System.out::println);
|
||||
// random.ints().limit(3).sorted().forEach(System.out::println);
|
||||
//使用map输出元数对应的平方数且去重
|
||||
List<Integer> integerList = Arrays.asList(1,3,5,7,9,2,4,6,8,10);
|
||||
integerList.stream().map(i -> i * i).distinct().collect(Collectors.toList());
|
||||
//取集合数据
|
||||
List<Users> usersList = new ArrayList<>();
|
||||
usersList.add(new Users("张三","男",15));
|
||||
usersList.add(new Users("李四","男",23));
|
||||
usersList.add(new Users("王五","男",18));
|
||||
Map<String, Users> hashMap = new HashMap<>();
|
||||
List<Map<String,Users>> list1 = new ArrayList<>();
|
||||
for (int i = 1; i <= usersList.size(); i++) {
|
||||
hashMap.put(i+"",usersList.get(i-1));
|
||||
list1.add(hashMap);
|
||||
}
|
||||
System.out.println(list1);
|
||||
List<Users> collect = list1.stream().map(item -> item.get("1")).collect(Collectors.toList());
|
||||
System.out.println(collect.get(0));
|
||||
//将一个对象的集合转换为另一个对象的集合
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
|
||||
public class Users {
|
||||
private String name;
|
||||
private String sex;
|
||||
private Integer age;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Users{" +
|
||||
"name='" + name + '\'' +
|
||||
", sex='" + sex + '\'' +
|
||||
", age=" + age +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Integer getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public Users(String name, String sex, int age) {
|
||||
this.name = name;
|
||||
this.sex = sex;
|
||||
this.age = age;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue