1
0
suochencheng 7 лет назад
Родитель
Сommit
fe17ea5b84

+ 2 - 2
src/main/java/com/izouma/awesomeadmin/dao/CommonQueryMapper.xml

@@ -8,7 +8,7 @@
 
         SELECT * FROM ${record.tableName}
         <where>
-            and del_flag = 'N'
+            and (del_flag = 'N' or del_flag = 0)
 
             <if test="record.advancedQuery != null and !&quot;&quot;.equals(record.advancedQuery)">
                 <foreach item="item" index="index" collection="record.advancedQuery.split('_;')">
@@ -76,7 +76,7 @@
 
         SELECT * FROM ${tableName}
         <where>
-            and del_flag = 'N'
+            and (del_flag = 'N' or del_flag = 0)
             <if test="advancedQuery != null and !&quot;&quot;.equals(advancedQuery)">
                 <foreach item="item" index="index" collection="advancedQuery.split('_;')">
                     <choose>

+ 1 - 1
src/main/java/com/izouma/awesomeadmin/dao/CommonQuerySqlServerMapper.java

@@ -7,7 +7,7 @@ import org.springframework.stereotype.Repository;
 import java.util.List;
 import java.util.Map;
 
-@DataSource("dataSourceSqlserver")
+@DataSource("dataSource")
 @Repository("com.izouma.awesomeadmin.dao.CommonQuerySqlServerMapper")
 public interface CommonQuerySqlServerMapper {
 

+ 12 - 0
src/main/java/com/izouma/awesomeadmin/dao/QueryConfigMapper.xml

@@ -9,6 +9,7 @@
         <result column="tableColumns" property="tablecolumns" jdbcType="VARCHAR"/>
         <result column="dataBaseType" property="databasetype" jdbcType="VARCHAR"/>
         <result column="modules" property="modules" jdbcType="VARCHAR"/>
+        <result column="data_source_code" property="dataSourceCode" jdbcType="VARCHAR"/>
     </resultMap>
     <sql id="Base_Column_List">
         <trim suffixOverrides=",">
@@ -26,6 +27,8 @@
 
             modules,
 
+            data_source_code,
+
         </trim>
     </sql>
     <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
@@ -63,6 +66,9 @@
             <if test="modules!= null">
                 modules,
             </if>
+            <if test="dataSourceCode!= null">
+                data_source_code,
+            </if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">
@@ -86,6 +92,9 @@
             <if test="modules != null">
                 #{modules,jdbcType=VARCHAR},
             </if>
+            <if test="dataSourceCode != null">
+                #{dataSourceCode,jdbcType=VARCHAR},
+            </if>
         </trim>
     </insert>
     <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.QueryConfig">
@@ -112,6 +121,9 @@
             <if test="modules != null">
                 modules= #{modules,jdbcType=VARCHAR},
             </if>
+            <if test="dataSourceCode != null">
+                data_source_code= #{dataSourceCode,jdbcType=VARCHAR},
+            </if>
         </set>
         where id = #{id,jdbcType=INTEGER}
     </update>

+ 0 - 2
src/main/java/com/izouma/awesomeadmin/datasource/DynamicDataSource.java

@@ -1,10 +1,8 @@
 package com.izouma.awesomeadmin.datasource;
 
-import com.izouma.awesomeadmin.dao.DataSourceInfoMapper;
 import com.izouma.awesomeadmin.model.DataSourceInfo;
 import com.izouma.awesomeadmin.util.Const;
 import org.apache.commons.dbcp.BasicDataSource;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
 
 import javax.sql.DataSource;

+ 10 - 0
src/main/java/com/izouma/awesomeadmin/model/CommonQuery.java

@@ -30,6 +30,8 @@ public class CommonQuery {
 
     private String primaryKey;
 
+    private String dataSourceCode;
+
 
     public String getTableName() {
         return tableName;
@@ -86,5 +88,13 @@ public class CommonQuery {
     public void setPrimaryKey(String primaryKey) {
         this.primaryKey = primaryKey;
     }
+
+    public String getDataSourceCode() {
+        return dataSourceCode;
+    }
+
+    public void setDataSourceCode(String dataSourceCode) {
+        this.dataSourceCode = dataSourceCode;
+    }
 }
 

+ 10 - 0
src/main/java/com/izouma/awesomeadmin/model/QueryConfig.java

@@ -14,6 +14,8 @@ public class QueryConfig {
     private String tablecolumns;
     private String databasetype;
 
+    private String dataSourceCode;
+
     private String modules;
 
     private String searchKey;
@@ -94,5 +96,13 @@ public class QueryConfig {
     public void setModules(String modules) {
         this.modules = modules;
     }
+
+    public String getDataSourceCode() {
+        return dataSourceCode;
+    }
+
+    public void setDataSourceCode(String dataSourceCode) {
+        this.dataSourceCode = dataSourceCode;
+    }
 }
 

+ 54 - 0
src/main/java/com/izouma/awesomeadmin/service/impl/CommonQueryServiceImpl.java

@@ -3,6 +3,7 @@ package com.izouma.awesomeadmin.service.impl;
 import com.izouma.awesomeadmin.constant.AppConstant;
 import com.izouma.awesomeadmin.dao.CommonQueryMapper;
 import com.izouma.awesomeadmin.dao.CommonQuerySqlServerMapper;
+import com.izouma.awesomeadmin.datasource.DataSource;
 import com.izouma.awesomeadmin.dto.Page;
 import com.izouma.awesomeadmin.model.CommonQuery;
 import com.izouma.awesomeadmin.model.TestAaa;
@@ -11,6 +12,9 @@ import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -34,6 +38,7 @@ public class CommonQueryServiceImpl implements CommonQueryService {
 
         logger.info("getTableListByPage");
         try {
+            changeDataSource(record.getDataSourceCode(), record.getDatabasetype());
 
             Map<String, Object> parameter = new HashMap<String, Object>();
             parameter.put("record", record);
@@ -59,6 +64,8 @@ public class CommonQueryServiceImpl implements CommonQueryService {
         logger.info("getTableListAll");
         try {
 
+            changeDataSource(record.getDataSourceCode(), record.getDatabasetype());
+
             if ("Mysql".equals(record.getDatabasetype())) {
 
                 return commonQueryMapper.getTableListAll(record);
@@ -80,6 +87,8 @@ public class CommonQueryServiceImpl implements CommonQueryService {
         logger.info("selectByPrimaryKey");
         try {
 
+            changeDataSource(record.getDataSourceCode(), record.getDatabasetype());
+
             if ("Mysql".equals(record.getDatabasetype())) {
                 return commonQueryMapper.selectByPrimaryKey(record);
             } else if ("SqlServer".equals(record.getDatabasetype())) {
@@ -99,6 +108,8 @@ public class CommonQueryServiceImpl implements CommonQueryService {
 
         logger.info("create");
         try {
+            changeDataSource(parameter.get("dataSourceCode").toString(), parameter.get("databasetype").toString());
+
             int updates = 0;
             if ("Mysql".equals(parameter.get("databasetype").toString())) {
                 updates = commonQueryMapper.insertSelective(parameter);
@@ -123,6 +134,7 @@ public class CommonQueryServiceImpl implements CommonQueryService {
 
         logger.info("update");
         try {
+            changeDataSource(parameter.get("dataSourceCode").toString(), parameter.get("databasetype").toString());
             int updates = 0;
             if ("Mysql".equals(parameter.get("databasetype").toString())) {
                 updates = commonQueryMapper.updateByPrimaryKeySelective(parameter);
@@ -145,8 +157,10 @@ public class CommonQueryServiceImpl implements CommonQueryService {
     @Override
     public boolean delete(CommonQuery record) {
 
+
         logger.info("delete");
         try {
+            changeDataSource(record.getDataSourceCode(), record.getDatabasetype());
             int updates = 0;
             if ("Mysql".equals(record.getDatabasetype())) {
                 updates = commonQueryMapper.delete(record);
@@ -165,6 +179,46 @@ public class CommonQueryServiceImpl implements CommonQueryService {
         return false;
     }
 
+    /**
+     * 切换数据库注解
+     *
+     * @param dateSourceCode
+     * @param databaseType
+     */
+    public void changeDataSource(String dateSourceCode, String databaseType) {
+
+        try {
+
+
+            //获取注解实例
+            DataSource foo = CommonQueryMapper.class.getAnnotation(DataSource.class);
+            if ("SqlServer".equals(databaseType)) {
+                foo = CommonQuerySqlServerMapper.class.getAnnotation(DataSource.class);
+            }
 
+            //获取注解实例的 value 属性值
+            String value = foo.value();
+            //打印该值
+            logger.info("修改之前的注解值:" + value);
+
+            logger.info("------------以下是修改注解的值------------");
+
+            //获取 foo 这个代理实例所持有的 InvocationHandler
+            InvocationHandler invocationHandler = Proxy.getInvocationHandler(foo);
+            // 获取 AnnotationInvocationHandler 的 memberValues 字段
+            Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
+            // 因为这个字段事 private final 修饰,所以要打开权限
+            declaredField.setAccessible(true);
+            // 获取 memberValues
+            Map memberValues = (Map) declaredField.get(invocationHandler);
+            // 修改 value 属性值
+            memberValues.put("value", dateSourceCode);
+            // 获取 foo 的 value 属性值
+            String newValue = foo.value();
+            logger.info("修改之后的注解值:" + newValue);
+        } catch (Exception e) {
+            logger.error("切换数据库失败", e);
+        }
+    }
 }
 

+ 4 - 1
src/main/java/com/izouma/awesomeadmin/util/DatabaseUtil.java

@@ -84,7 +84,8 @@ public class DatabaseUtil {
         PropertiesFileLoader propertiesFileLoader = PropertiesFileLoader.getInstance();
 
         String databaseName = propertiesFileLoader.getProperties("properties/jdbc.properties", "jdbc.databaseName");
-        String sql = "select * from information_schema.columns where  table_schema ='" + databaseName + "' and table_name = '" + dataSourceInfo.getTableName() + "' ;";
+        String sql = "select * from information_schema.columns where  table_schema ='" + databaseName
+                + "' and table_name = '" + dataSourceInfo.getTableName() + "' ;";
 
         String url = propertiesFileLoader.getProperties("properties/jdbc.properties", "jdbc.url");
         String user = propertiesFileLoader.getProperties("properties/jdbc.properties", "jdbc.username");
@@ -100,6 +101,8 @@ public class DatabaseUtil {
                 url = "jdbc:mysql://" + dataSourceInfo.getUrl() + "/" + dataSourceInfo.getDatabaseName();
                 user = dataSourceInfo.getUsername();
                 password = dataSourceInfo.getPassword();
+                sql = "select * from information_schema.columns where  table_schema ='" + dataSourceInfo.getDatabaseName()
+                        + "' and table_name = '" + dataSourceInfo.getTableName() + "' ;";
             } else if ("SqlServer".equals(dataSourceInfo.getDatabaseType())) {
                 DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
                 url = "jdbc:sqlserver://" + dataSourceInfo.getUrl() + ";DatabaseName=" + dataSourceInfo.getDatabaseName();

+ 1 - 1
src/main/java/com/izouma/awesomeadmin/web/GenCodeController.java

@@ -213,7 +213,7 @@ public class GenCodeController extends BaseController {
     @ResponseBody
     public Result tables(DataSourceInfo dataSourceInfo) {
 
-        if (StringUtils.isNotEmpty(dataSourceInfo.getCode())) {
+        if (StringUtils.isNotEmpty(dataSourceInfo.getCode()) && !"dataSource".equals(dataSourceInfo.getCode())) {
             dataSourceInfo = dataSourceInfoService.getDataSourceInfo(dataSourceInfo);
             if (dataSourceInfo != null) {
 

+ 5 - 2
src/main/vue/src/pages/CommonQuery.vue

@@ -50,6 +50,7 @@ export default {
             databasetype: 'Mysql',
             tableName: '',
             modules: [],
+            dataSourceCode: '',
         }
     },
     methods: {
@@ -97,6 +98,7 @@ export default {
                 tableName: this.tableName,
                 primaryKey: this.formData.id || this.formData.ID,
                 databasetype: this.databasetype,
+                dataSourceCode: this.dataSourceCode,
             };
             this.$http.post({
                 url: this.formData.id || this.formData.ID ? '/commonQuery/update' : '/commonQuery/save',
@@ -117,7 +119,8 @@ export default {
                     data: {
                         tableName: this.tableName,
                         primaryKey: this.$route.query.id,
-                        databasetype: this.databasetype
+                        databasetype: this.databasetype,
+                        dataSourceCode: this.dataSourceCode,
                     }
                 }).then(res => {
                     if (res.success) {
@@ -151,7 +154,7 @@ export default {
 
                         this.tableName = res.data.tableName;
                         this.databasetype = res.data.databasetype;
-
+                        this.dataSourceCode = res.data.dataSourceCode;
                         this.tableColumns = [];
                         var tableColumnsStr = res.data.tablecolumns;
 

+ 8 - 2
src/main/vue/src/pages/CommonQuerys.vue

@@ -133,6 +133,7 @@ export default {
             searchColumn: '',
             orderByStr: '',
             modules: [],
+            dataSourceCode: 'dataSource'
 
         }
     },
@@ -147,6 +148,10 @@ export default {
             this.tableColumns = [];
             this.tableData = [];
             this.modules = [];
+            this.filter1= '';
+            this.advancedQuerySearchKey='';
+            this.orderByStr = '';
+            
             this.$http.get({
                 url: '/queryConfig/getOne',
                 data: {
@@ -164,7 +169,7 @@ export default {
 
                         this.tableName = res.data.tableName;
                         this.databasetype = res.data.databasetype;
-
+                        this.dataSourceCode = res.data.dataSourceCode;
 
                         var tableColumnsStr = res.data.tablecolumns;
 
@@ -230,7 +235,8 @@ export default {
                     databasetype: this.databasetype,
                     searchColumn: this.searchColumn,
                     searchKey: this.filter1,
-                    orderByStr: this.orderByStr
+                    orderByStr: this.orderByStr,
+                    dataSourceCode:this.dataSourceCode,
                 }
             }).then(res => {
                 if (res.success) {

+ 128 - 14
src/main/vue/src/pages/QueryConfig.vue

@@ -1,8 +1,8 @@
 <template>
     <div>
-        <el-form :model="formData" :rules="rules" ref="form" label-width="80px" label-position="right" size="small" style="max-width: 500px;">
-            <el-form-item prop="databasetype" label="数据库">
-                <el-select placeholder="数据库" size="small" v-model="formData.databasetype" class="filter-item">
+        <el-form :model="formData" :rules="rules" ref="form" label-width="80px" label-position="right" size="small">
+            <el-form-item prop="databasetype" label="库类型">
+                <el-select placeholder="库类型" size="small" v-model="formData.databasetype" @change="changeDataBaseType" class="filter-item">
                     <el-option label="Mysql" value="Mysql">
                     </el-option>
                     <el-option label="SqlServer" value="SqlServer">
@@ -10,11 +10,24 @@
                 </el-select>
             </el-form-item>
 
-            <el-form-item prop="code" label="code">
-                <el-input v-model="formData.code"></el-input>
+            <el-form-item prop="dataSourceCode" label="数据库">
+
+                <el-select placeholder="数据库" size="small" v-model="formData.dataSourceCode" @change="changeDataSourceCode" class="filter-item">
+                    <el-option v-for="item in datasourceInfoList" :label="item.databaseName" :value="item.code" :key="item.code"></el-option>
+                </el-select>
+
             </el-form-item>
+
             <el-form-item prop="tableName" label="表名">
-                <el-input v-model="formData.tableName"></el-input>
+
+                <el-select placeholder="表名" size="small" clearable filterable v-model="formData.tableName" @change="changeTableName" class="filter-item">
+                    <el-option v-for="item in tableList" :label="item" :value="item" :key="item"></el-option>
+                </el-select>
+
+            </el-form-item>
+
+            <el-form-item prop="code" label="code" style="width:300px;">
+                <el-input v-model="formData.code"></el-input>
             </el-form-item>
 
             <el-form-item prop="modules" label="功能">
@@ -36,16 +49,18 @@
                 <el-button @click="addField" type="text" icon="el-icon-plus">添加</el-button>
                 <el-table :data="tablecolumnsFields">
 
-                    <el-table-column prop="name" label="显示" align="center">
+                    <el-table-column prop="value" label="字段" width="150" align="center">
                         <template slot-scope="{row}">
-                            <el-input v-model="row.label"></el-input>
+                            <el-input v-model="row.value"></el-input>
                         </template>
                     </el-table-column>
-                    <el-table-column prop="value" label="字段" align="center">
+
+                    <el-table-column prop="name" label="显示" width="150" align="center">
                         <template slot-scope="{row}">
-                            <el-input v-model="row.value"></el-input>
+                            <el-input v-model="row.label"></el-input>
                         </template>
                     </el-table-column>
+
                     <el-table-column prop="type" label="类型" width="150" align="center">
                         <template slot-scope="{row}">
                             <el-select v-model="row.type">
@@ -106,12 +121,38 @@ export default {
                 }
             })
         }
+
+        this.$http.get({
+            url: '/dataSourceInfo/all'
+        }).then(res => {
+            if (res.success) {
+                this.MysqlDataSourceInfos.push(this.baseDataSource);
+
+                if (res.data.length > 0) {
+                    res.data.forEach(item => {
+                        if ('Mysql' == item.databaseType) {
+                            this.MysqlDataSourceInfos.push(item);
+                        } else if ('SqlServer' == item.databaseType) {
+                            this.SqlServerDataSourceInfos.push(item);
+                        }
+                    })
+                }
+                this.datasourceInfoList = this.MysqlDataSourceInfos;
+            }
+        });
+
+
+        this.getDatabaseTables();
+
     },
     data() {
         return {
             saving: false,
             formData: {
-                databasetype: 'Mysql'
+                databasetype: 'Mysql',
+                dataSourceCode: 'dataSource',
+                tableName: '',
+                modules: []
             },
             rules: {
                 databasetype: [
@@ -123,12 +164,12 @@ export default {
                 modules: [
                     { required: true, message: '请选择功能', trigger: 'blur' },
                 ],
-                tablecolumns: [
-                    { required: true, message: '请添加字段', trigger: 'blur' },
-                ],
                 tableName: [
                     { required: true, message: '请填写表名', trigger: 'blur' },
                 ],
+                dataSourceCode: [
+                    { required: true, message: '请填选择数据库', trigger: 'blur' },
+                ],
             },
 
             tablecolumnsFields: [
@@ -139,6 +180,17 @@ export default {
                 { label: '日期', value: 'date' },
                 { label: '图片', value: 'image' },
             ],
+            MysqlDataSourceInfos: [],
+            SqlServerDataSourceInfos: [],
+            baseDataSource: {
+                databaseType: 'Mysql',
+                code: 'dataSource',
+                databaseName: '基础数据库'
+
+            },
+            datasourceInfoList: [],
+            tableList: [],
+
 
         }
     },
@@ -204,6 +256,68 @@ export default {
                 this.tablecolumnsFields.splice(i, 1);
             }
         },
+        changeDataBaseType() {
+            if ('Mysql' == this.formData.databasetype) {
+                this.datasourceInfoList = this.MysqlDataSourceInfos;
+                this.formData.dataSourceCode = 'dataSource';
+                this.getDatabaseTables();
+            } else if ('SqlServer' == this.formData.databasetype) {
+                this.datasourceInfoList = this.SqlServerDataSourceInfos;
+                this.formData.dataSourceCode = '';
+            }
+        },
+        getDatabaseTables(code) {
+            this.tableList = [];
+            this.$http.get({
+                url: '/genCode/tables',
+                data: {
+                    code: code
+                }
+            }).then(res => {
+                if (res.success) {
+
+                    this.tableList = res.data;
+                }
+            })
+        },
+        changeDataSourceCode() {
+
+            this.formData.tableName = '';
+            this.getDatabaseTables(this.formData.dataSourceCode);
+        },
+        changeTableName() {
+
+            this.tablecolumnsFields = [];
+
+            this.getTableFields(this.formData.tableName);
+        },
+        getTableFields(tableName) {
+            this.$http.get({
+                url: '/genCode/tableFields',
+                data: {
+                    code: this.formData.dataSourceCode,
+                    tableName: tableName,
+                    databaseType: this.formData.databasetype,
+                }
+            }).then(res => {
+                if (res.success) {
+
+
+
+                    //this.tablecolumnsFields = res.data;
+
+                    res.data.forEach(item => {
+
+                        this.tablecolumnsFields.push({
+                            label: item.remark,
+                            value: item.name,
+                            type: 'text',
+                        })
+                    })
+
+                }
+            })
+        },
     }
 }
 </script>

+ 270 - 0
src/main/vue/src/pages/TestAaaLineChart.vue

@@ -0,0 +1,270 @@
+<template>
+    <div>
+        <div class="filters-container">
+
+            <el-input placeholder="关键字" size="small" v-model="filter1" clearable class="filter-item"></el-input>
+            <el-button @click="searchData" type="primary" size="small" icon="el-icon-search" class="filter-item">搜索
+            </el-button>
+            <el-button @click="showAdvancedQueryDialog = !showAdvancedQueryDialog" type="primary" size="small" icon="el-icon-search" class="filter-item">高级查询
+            </el-button>
+        </div>
+        <el-dialog title="高级查询" :visible.sync="showAdvancedQueryDialog">
+            <el-button @click="addField" type="text" icon="el-icon-plus">添加</el-button>
+            <el-table :data="advancedQueryFields">
+
+                <el-table-column prop="link" label="链接符" align="center">
+                    <template slot-scope="{row}">
+                        <el-select placeholder="链接" size="small" v-model="row.link" class="filter-item">
+                            <el-option label="AND" value="AND">
+                            </el-option>
+                            <el-option label="OR" value="OR">
+                            </el-option>
+                        </el-select>
+                    </template>
+                </el-table-column>
+                <el-table-column prop="name" label="字段" align="center">
+                    <template slot-scope="{row}">
+                        <el-select v-model="row.name">
+
+                            <el-option v-for="item in advancedQueryColumns" :label="item.label" :value="item.value" :key="item.value"></el-option>
+                        </el-select>
+                    </template>
+                </el-table-column>
+                <el-table-column prop="searchMethod" label="搜索方式" width="150" align="center">
+                    <template slot-scope="{row}">
+                        <el-select v-model="row.searchMethod">
+                            <el-option v-for="item in searchMethods" :label="item" :value="item" :key="item"></el-option>
+                        </el-select>
+                    </template>
+                </el-table-column>
+                <el-table-column prop="value" label="参数" align="center">
+                    <template slot-scope="{row}">
+                        <el-input v-model="row.value"></el-input>
+                    </template>
+                </el-table-column>
+                <el-table-column width="60" align="center">
+                    <template slot-scope="{ row, column, $index }">
+                        <el-button @click="removeField($index)" size="small" type="text">删除</el-button>
+                    </template>
+                </el-table-column>
+            </el-table>
+
+            <span slot="footer" class="dialog-footer">
+
+                <el-button @click="advancedQuery" :loading="$store.state.fetchingData">确定</el-button>
+            </span>
+        </el-dialog>
+
+        <line-chart ref="line" :height='200' :chartData='lineData' :options='lineOptions' style="max-width:1000px;margin:auto"></line-chart>
+    </div>
+</template>
+<script>
+import { mapState } from 'vuex'
+import { format } from 'date-fns'
+import zh from 'date-fns/locale/zh_cn'
+import lineChart from '../components/Line'
+
+export default {
+    created() {
+    },
+    data() {
+        return {
+            filter1: '',
+            multipleMode: false,
+            showAdvancedQueryDialog: false,
+            advancedQueryFields: [],
+            searchMethods: ['=', '!=', '>', '>=', '<', '<=', 'like'],
+            advancedQueryColumns: [
+                {
+                    label: 'id',
+                    value: 'id'
+                },
+                {
+                    label: '名字',
+                    value: 'test_name'
+                },
+                {
+                    label: '备注',
+                    value: 'remark'
+                },
+                {
+                    label: '图片',
+                    value: 'image_url'
+                },
+                {
+                    label: '时间',
+                    value: 'test_time'
+                },
+                {
+                    label: '多选',
+                    value: 'multi_select'
+                },
+            ],
+            advancedQuerySearchKey: '',
+            lineData: null,
+            lineOptions: {
+                responsive: true,
+                title: {
+                    display: true,
+                    text: '折线图'
+                },
+                tooltips: {
+                    mode: 'index',
+                    intersect: false,
+                },
+                // hover: {
+                //     mode: 'nearest',
+                //     intersect: true
+                // },
+                scales: {
+                    xAxes: [{
+                        display: true,
+                        scaleLabel: {
+                            display: true,
+                            labelString: 'Month'
+                        }
+                    }],
+                    yAxes: [{
+                        display: true,
+                        scaleLabel: {
+                            display: true,
+                            labelString: 'Value'
+                        }
+                    }]
+                }
+            },
+            chartColors: {
+                red: 'rgb(255, 99, 132)',
+                orange: 'rgb(255, 159, 64)',
+                yellow: 'rgb(255, 205, 86)',
+                green: 'rgb(75, 192, 192)',
+                blue: 'rgb(54, 162, 235)',
+                purple: 'rgb(153, 102, 255)',
+                grey: 'rgb(201, 203, 207)'
+            },
+        }
+    },
+    mounted() {
+        this.getData()
+    },
+    methods: {
+        getData() {
+            this.type = this.$route.query.type
+            this.$http.get({
+                url: '/testAaa/all',
+                data: {
+                    searchKey: this.filter1,
+                    advancedQuery: this.advancedQuerySearchKey,
+                }
+            }).then(res => {
+                if (res.success) {
+                    var tempLables = [];
+                    var tempDatasetsLabels = [];
+
+                    res.data.forEach(item => {
+                        tempLables.push(item.testName);
+                        tempDatasetsLabels.push(item.remark);
+                    })
+
+                    tempLables = Array.from(new Set(tempLables));
+
+                    tempDatasetsLabels = Array.from(new Set(tempDatasetsLabels))
+
+                    var tempDatasets = []
+
+                    tempDatasetsLabels.forEach((item, index) => {
+
+                        var colorNames = Object.keys(this.chartColors);
+                        var colorName = colorNames[(index + 1) % colorNames.length];
+
+                        var tempData = [];
+
+                        tempLables.forEach(item2 => {
+                            var datavalue = null;
+                            res.data.forEach(item3 => {
+                                if (item2 == item3.testName && item == item3.remark) {
+                                    datavalue = item3.multiSelect;
+                                }
+                            })
+
+                            tempData.push(datavalue)
+                        })
+
+                        var newDataset = {
+                            label: item,
+                            backgroundColor: this.chartColors[colorName],
+                            borderColor: this.chartColors[colorName],
+                            data: tempData,
+                            fill: false
+                        }
+
+                        tempDatasets.push(newDataset);
+
+                    })
+
+                    this.lineData = {
+                        datasets: tempDatasets,
+                        labels: tempLables,
+
+                    }
+
+
+                    this.$refs.line.updateChart()
+
+
+
+
+                }
+            })
+        },
+        addField() {
+            this.advancedQueryFields.push({
+                link: 'AND',
+                name: '',
+                searchMethod: '=',
+                value: '',
+            });
+        },
+        removeField(i) {
+            if (this.advancedQueryFields.length > 0) {
+                this.advancedQueryFields.splice(i, 1);
+            }
+        },
+        advancedQuery() {
+
+            this.advancedQuerySearchKey = '';
+
+            if (this.advancedQueryFields.length > 0) {
+
+                var templist = [];
+
+                this.advancedQueryFields.forEach(item => {
+                    if (item.link && item.name && item.searchMethod && item.value) {
+                        var tempItem = item.link + '_,' + item.name + '_,' + item.searchMethod + '_,' + item.value;
+                        templist.push(tempItem);
+                    }
+                })
+
+                if (templist.length > 0) {
+
+                    this.advancedQuerySearchKey = templist.join('_;');
+                }
+            }
+
+            this.getData();
+            this.$refs.line.updateChart()
+            this.showAdvancedQueryDialog = false;
+        },
+        searchData() {
+            this.getData();
+            setTimeout(() => {
+
+            }, 1000)
+        },
+
+    },
+    components: { lineChart }
+}
+</script>
+<style lang="less" scoped>
+</style>

+ 5 - 0
src/main/vue/src/router/index.js

@@ -155,6 +155,11 @@ const router = new Router({
                     name: 'testAaa',
                     component: () => import('../pages/TestAaa')
                 },
+                {
+                    path: '/testAaaLineChart',
+                    name: 'testAaaLineChart',
+                    component: () => import('../pages/TestAaaLineChart')
+                },
                 {
                     path: '/commonQuerys',
                     name: 'commonQuerys',

+ 47 - 0
src/test/java/DatabaseServiceTest.java

@@ -1,18 +1,29 @@
+import com.izouma.awesomeadmin.dao.CommonQueryMapper;
+import com.izouma.awesomeadmin.datasource.DataSource;
+import com.izouma.awesomeadmin.model.CommonQuery;
 import com.izouma.awesomeadmin.util.DatabaseUtil;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.support.GenericXmlContextLoader;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
 import java.util.List;
+import java.util.Map;
 
 @RunWith(value = SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = {"classpath:/spring/applicationContext.xml"}, loader = GenericXmlContextLoader.class)
 @Transactional
 public class DatabaseServiceTest {
 
+    @Autowired
+    private CommonQueryMapper commonQueryMapper;
+
     @Test
     public void testLoadDatabaseTables() {
 
@@ -21,4 +32,40 @@ public class DatabaseServiceTest {
         System.out.println(tables);
     }
 
+    @Test
+    public void test() throws NoSuchFieldException, IllegalAccessException {
+        CommonQuery commonQuery = new CommonQuery();
+        commonQuery.setTableName("test_aaa");
+
+        commonQueryMapper.getTableListAll(commonQuery);
+
+        //获取val字段上的Foo注解实例
+        DataSource foo = CommonQueryMapper.class.getAnnotation(DataSource.class);
+        //获取Foo注解实例的 value 属性值
+        String value = foo.value();
+        //打印该值
+        System.out.println("修改之前的注解值:" + value);
+
+        System.out.println("------------以下是修改注解的值------------");
+
+        //获取 foo 这个代理实例所持有的 InvocationHandler
+        InvocationHandler invocationHandler = Proxy.getInvocationHandler(foo);
+        // 获取 AnnotationInvocationHandler 的 memberValues 字段
+        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
+        // 因为这个字段事 private final 修饰,所以要打开权限
+        declaredField.setAccessible(true);
+        // 获取 memberValues
+        Map memberValues = (Map) declaredField.get(invocationHandler);
+        // 修改 value 属性值
+        memberValues.put("value", "dataSourceSqlserver");
+        // 获取 foo 的 value 属性值
+        String newValue = foo.value();
+        System.out.println("修改之后的注解值:" + newValue);
+
+        commonQueryMapper.getTableListAll(commonQuery);
+
+
+    }
+
+
 }