This commit is contained in:
20932067@zju.edu.cn 2021-01-31 08:51:43 +08:00
parent 17a5c677e8
commit 916051d3ec
29 changed files with 1976 additions and 186 deletions

View File

@ -8,7 +8,7 @@ npm install --registry=https://registry.npm.taobao.org
npm run dev
```
浏览器访问 http://localhost:80
浏览器访问 http://localhost:8080
## 发布

View File

@ -8,7 +8,12 @@ export function listStu(query) {
params: query
})
}
export function mapTest(){
return request({
url: '/test/map',
method: 'get',
})
}
// 查询学生详细
export function getStu(id) {
return request({
@ -50,4 +55,4 @@ export function exportStu(query) {
method: 'get',
params: query
})
}
}

View File

@ -0,0 +1,78 @@
import request from '@/utils/request'
// 查询万能查询列表
export function listQuery(query) {
return request({
url: '/tool/query/list',
method: 'get',
params: query
})
}
// 查询万能查询详细
export function getQuery(id) {
return request({
url: '/tool/query/' + id,
method: 'get'
})
}
// 新增万能查询
export function addQuery(data) {
return request({
url: '/tool/query',
method: 'post',
data: data
})
}
// 修改万能查询
export function updateQuery(data) {
return request({
url: '/tool/query',
method: 'put',
data: data
})
}
// 删除万能查询
export function delQuery(id) {
return request({
url: '/tool/query/' + id,
method: 'delete'
})
}
// 导出万能查询
export function exportQuery(query) {
return request({
url: '/tool/query/export',
method: 'get',
params: query
})
}
// 获取条件
export function getQueryInfo(id) {
return request({
url: '/query/'+id,
method: 'get',
})
}
// 修改条件
export function editQueryInfo(data) {
return request({
url: '/query',
method: 'put',
data: data
})
}
// 预览
export function previewQueryData(data) {
return request({
url: '/query/preview',
method: 'put',
data: data
})
}

View File

@ -118,6 +118,19 @@ export const constantRoutes = [
}
]
},
{
path: '/query',
component: Layout,
hidden: true,
children: [
{
path: 'edit/:queryId(\\d+)',
component: (resolve) => require(['@/views/tool/query/uniQuery'], resolve),
name: 'UniQuery',
meta: { title: '万能查询配置' }
}
]
},
{
path: '/job',
component: Layout,

View File

@ -55,7 +55,8 @@
size="mini"
@click="handleAdd"
v-hasPermi="['test:stu:add']"
>新增</el-button>
>新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
@ -66,7 +67,8 @@
:disabled="single"
@click="handleUpdate"
v-hasPermi="['test:stu:edit']"
>修改</el-button>
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
@ -77,7 +79,8 @@
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['test:stu:remove']"
>删除</el-button>
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
@ -87,17 +90,18 @@
size="mini"
@click="handleExport"
v-hasPermi="['test:stu:export']"
>导出</el-button>
>导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="stuList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="id" align="center" prop="id" />
<el-table-column label="学生姓名" align="center" prop="name" />
<el-table-column label="电话" align="center" prop="tel" />
<el-table-column label="电子邮件" align="center" prop="email" />
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="id" align="center" prop="id"/>
<el-table-column label="学生姓名" align="center" prop="name"/>
<el-table-column label="电话" align="center" prop="tel"/>
<el-table-column label="电子邮件" align="center" prop="email"/>
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
@ -111,18 +115,20 @@
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['test:stu:edit']"
>修改</el-button>
>修改
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['test:stu:remove']"
>删除</el-button>
>删除
</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
@ -135,13 +141,13 @@
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="学生姓名" prop="name">
<el-input v-model="form.name" placeholder="请输入学生姓名" />
<el-input v-model="form.name" placeholder="请输入学生姓名"/>
</el-form-item>
<el-form-item label="电话" prop="tel">
<el-input v-model="form.tel" placeholder="请输入电话" />
<el-input v-model="form.tel" placeholder="请输入电话"/>
</el-form-item>
<el-form-item label="电子邮件" prop="email">
<el-input v-model="form.email" placeholder="请输入电子邮件" />
<el-input v-model="form.email" placeholder="请输入电子邮件"/>
</el-form-item>
<el-divider content-position="center">成绩信息</el-divider>
<el-row :gutter="10" class="mb8">
@ -152,22 +158,23 @@
<el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteResults">删除</el-button>
</el-col>
</el-row>
<el-table :data="resultsList" :row-class-name="rowResultsIndex" @selection-change="handleResultsSelectionChange" ref="results">
<el-table-column type="selection" width="50" align="center" />
<el-table :data="resultsList" :row-class-name="rowResultsIndex" @selection-change="handleResultsSelectionChange"
ref="results">
<el-table-column type="selection" width="50" align="center"/>
<el-table-column label="序号" align="center" prop="index" width="50"/>
<el-table-column label="java成绩" prop="java">
<template slot-scope="scope">
<el-input v-model="scope.row.java" placeholder="请输入java成绩" />
<el-input v-model="scope.row.java" placeholder="请输入java成绩"/>
</template>
</el-table-column>
<el-table-column label="图片路径" prop="images">
<template slot-scope="scope">
<el-input v-model="scope.row.images" placeholder="请输入图片路径" />
<el-input v-model="scope.row.images" placeholder="请输入图片路径"/>
</template>
</el-table-column>
<el-table-column label="文件路径" prop="file">
<template slot-scope="scope">
<el-input v-model="scope.row.file" placeholder="请输入文件路径" />
<el-input v-model="scope.row.file" placeholder="请输入文件路径"/>
</template>
</el-table-column>
</el-table>
@ -177,16 +184,25 @@
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<el-dialog :title="maptest.title" :visible.sync="maptest.open" width="1200px" append-to-body>
<el-table v-loading="false" :data="maptest.tabledata">
<el-table-column v-for="item in maptest.tableheader"
:label="item"
align="center"
:key="item"
:prop="item" />
</el-table>
</el-dialog>
</div>
</template>
<script>
import { listStu, getStu, delStu, addStu, updateStu, exportStu } from "@/api/test/stu";
import {listStu, getStu, delStu, addStu, updateStu, exportStu, mapTest} from "@/api/test/stu";
export default {
name: "Stu",
components: {
},
components: {},
data() {
return {
//
@ -211,6 +227,12 @@ export default {
title: "",
//
open: false,
maptest: {
open: true,
title: "map测试",
tabledata: [],
tableheader: [],
},
//
daterangeCreateTime: [],
//
@ -226,27 +248,38 @@ export default {
//
rules: {
name: [
{ required: true, message: "学生姓名不能为空}", trigger: "blur" },
{required: true, message: "学生姓名不能为空}", trigger: "blur"},
],
tel: [
{ required: true, message: "电话不能为空}", trigger: "blur" },
{ pattern: /^1[0-9]{10}$/, message: '电话格式有误', trigger:"blur"},
{required: true, message: "电话不能为空}", trigger: "blur"},
{pattern: /^1[0-9]{10}$/, message: '电话格式有误', trigger: "blur"},
],
email: [
{ required: true, message: "电子邮件不能为空}", trigger: "blur" },
{ pattern: /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/, message: '电子邮件格式有误', trigger:"blur"},
{required: true, message: "电子邮件不能为空}", trigger: "blur"},
{
pattern: /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
message: '电子邮件格式有误',
trigger: "blur"
},
],
}
};
},
created() {
this.getList();
mapTest().then(res => {
this.maptest.tabledata = res
this.maptest.tableheader = []
for (var key in res[0]) {
this.maptest.tableheader.push(key)
}
})
},
methods: {
/** 查询学生列表 */
getList() {
this.loading = true;
listStu(this.addCreateDateRange(this.queryParams,this.daterangeCreateTime)).then(response =>{
listStu(this.addCreateDateRange(this.queryParams, this.daterangeCreateTime)).then(response => {
this.stuList = response.rows;
this.total = response.total;
this.loading = false;
@ -282,7 +315,7 @@ export default {
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
@ -327,18 +360,18 @@ export default {
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除学生编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delStu(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
})
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
return delStu(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
})
},
/** 成绩序号 */
rowResultsIndex({ row, rowIndex }) {
/** 成绩序号 */
rowResultsIndex({row, rowIndex}) {
row.index = rowIndex + 1;
},
/** 成绩添加按钮操作 */
@ -352,7 +385,7 @@ export default {
/** 成绩删除按钮操作 */
handleDeleteResults() {
if (this.checkedResults.length == 0) {
this.$alert("请先选择要删除的成绩数据", "提示", { confirmButtonText: "确定", });
this.$alert("请先选择要删除的成绩数据", "提示", {confirmButtonText: "确定",});
} else {
this.resultsList.splice(this.checkedResults[0].index - 1, 1);
}
@ -370,14 +403,14 @@ export default {
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有学生数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return exportStu(queryParams);
}).then(response => {
this.download(response.msg);
})
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
return exportStu(queryParams);
}).then(response => {
this.download(response.msg);
})
}
}
};

View File

@ -138,7 +138,10 @@
})
}
},
methods:{
methods:{ /** 删除按钮 */
handleDelete(index, row) {
this.cloumns.splice(index, 1);
},
/** 提交按钮 */
submitForm() {
const moduleForm = this.$refs.moduleInfo.$refs.moduleInfoForm;

View File

@ -0,0 +1,320 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="名称" prop="uqName">
<el-input
v-model="queryParams.uqName"
placeholder="请输入名称"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="描述" prop="uqDescribe">
<el-input
v-model="queryParams.uqDescribe"
placeholder="请输入描述"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="创建时间">
<el-date-picker
v-model="daterangeCreateTime"
size="small"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['tool:query:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['tool:query:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['tool:query:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['tool:query:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="queryList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column type="index" width="50"></el-table-column>
<!-- <el-table-column label="id" align="center" prop="id" />-->
<el-table-column label="名称" align="center" prop="uqName" />
<el-table-column label="描述" align="center" prop="uqDescribe" />
<el-table-column label="创建时间" align="center" prop="createTime">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column label="更新时间" align="center" prop="updateTime">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['tool:query:edit']"
>修改</el-button>
<el-button
type="text"
size="small"
icon="el-icon-edit-outline"
@click="handleEditTable(scope.row)"
v-hasPermi="['tool:query:update']"
>编辑</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['tool:query:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改万能查询对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="名称" prop="uqName">
<el-input v-model="form.uqName" placeholder="请输入名称" />
</el-form-item>
<el-form-item label="sql语句" prop="uqSql">
<el-input v-model="form.uqSql" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="描述" prop="uqDescribe">
<el-input v-model="form.uqDescribe" placeholder="请输入描述" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listQuery, getQuery, delQuery, addQuery, updateQuery, exportQuery } from "@/api/tool/query";
export default {
name: "Query",
components: {
},
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
queryList: [],
//
title: "",
//
open: false,
//
daterangeCreateTime: [],
//
queryParams: {
pageNum: 1,
pageSize: 10,
uqName: null,
uqDescribe: null,
},
//
form: {},
//
rules: {
uqName: [
{ required: true, message: "名称不能为空}", trigger: "blur" },
],
uqDescribe: [
{ required: true, message: "描述不能为空}", trigger: "blur" },
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询万能查询列表 */
getList() {
this.loading = true;
listQuery(this.addCreateDateRange(this.queryParams,this.daterangeCreateTime)).then(response =>{
this.queryList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
uqName: null,
uqSql: null,
uqDescribe: null,
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
handleEditTable(row){
this.$router.push("/query/edit/" + row.id);
},
/** 重置按钮操作 */
resetQuery() {
this.daterangeCreateTime = [];
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加万能查询";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getQuery(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改万能查询";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateQuery(this.form).then(response => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addQuery(this.form).then(response => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除万能查询编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delQuery(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
})
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有万能查询数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return exportQuery(queryParams);
}).then(response => {
this.download(response.msg);
})
}
}
};
</script>

View File

@ -0,0 +1,267 @@
<template>
<div>
<div class="form-header">
<el-row :gutter="15">
<el-form ref="elForm" :model="info" :rules="rules" size="medium" label-width="100px">
<el-col :span="18">
<el-form-item label-width="1px" label="">
<el-input v-model="info.uqSql" type="textarea" placeholder="请输入sql"
:autosize="{minRows: 7, maxRows: 7}" :style="{width: '100%'}"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label-width="55px" label="名称" prop="uqName">
<el-input v-model="info.uqName" placeholder="请输入名称" clearable :style="{width: '100%'}">
</el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label-width="55px" label="描述" prop="uqDescribe">
<el-input v-model="info.uqDescribe" placeholder="请输入描述" clearable :style="{width: '100%'}">
</el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-button type="text" icon="el-icon-upload" size="medium" @click="submitForm">提交</el-button>
<el-button type="text" icon="el-icon-view" size="medium" @click="previewQuery">预览</el-button>
<el-button type="text" icon="el-icon-plus" size="medium" @click="handleAdd"
v-hasPermi="['tool:module:export']">新增
</el-button>
<el-button type="text" icon="el-icon-download" size="medium" v-hasPermi="['tool:module:export']">导出
</el-button>
</el-col>
</el-form>
</el-row>
<el-row>
<el-table ref="dragTable" :data="cloumns" row-key="columnId" :max-height="tableHeight">
<el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag"/>
<el-table-column label="条件描述" min-width="10%">
<template slot-scope="scope">
<el-input v-model="scope.row.ucDescribe"></el-input>
</template>
</el-table-column>
<el-table-column label="key" min-width="10%">
<template slot-scope="scope">
<el-input v-model="scope.row.ucKey"></el-input>
</template>
</el-table-column>
<el-table-column label="条件" min-width="10%">
<template slot-scope="scope">
<el-select v-model="scope.row.ucName" @change="ucTypeChang(scope.$index,scope.row)">
<el-option label="=" value="EQ"/>
<el-option label="!=" value="NE"/>
<el-option label=">" value="GT"/>
<el-option label=">=" value="GTE"/>
<el-option label="<" value="LT"/>
<el-option label="<=" value="LTE"/>
<el-option label="LIKE" value="LIKE"/>
<el-option label="BETWEEN" value="BETWEEN"/>
</el-select>
</template>
</el-table-column>
<el-table-column label="显示类型" min-width="12%">
<template slot-scope="scope">
<el-select v-model="scope.row.ucType" @change="ucTypeChang(scope.$index,scope.row)">
<el-option label="文本框" value="input"/>
<el-option label="日期控件" value="datetime"/>
</el-select>
</template>
</el-table-column>
<el-table-column label="模拟数据" min-width="10%">
<template slot-scope="scope">
<el-input v-if="scope.row.type == 1" v-model="scope.row.ucMock"></el-input>
<div v-else-if="scope.row.type == 2">
<el-row :gutter="15">
<el-col :span="12">
<el-input placeholder="开始值" v-model="scope.row.ucMock.begin"></el-input>
</el-col>
<el-col :span="12">
<el-input placeholder="结束值" v-model="scope.row.ucMock.end"></el-input>
</el-col>
</el-row>
</div>
<el-date-picker
v-else-if="scope.row.type ==3"
v-model="scope.row.ucMock"
type="datetime"
placeholder="选择日期时间">
</el-date-picker>
<el-date-picker v-else-if="scope.row.type ==4"
v-model="scope.row.ucMock"
size="small"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</template>
</el-table-column>
<el-table-column label="操作" align="center" min-width="5%">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.$index,scope.row)"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-row>
</div>
<div class="table-fixed">
<el-table v-show="previewDate.open" :data="previewDate.data">
</el-table>
</div>
</div>
</template>
<script>
import {getQueryInfo, editQueryInfo, previewQueryData} from '@/api/tool/query'
function JSONString(list){
for (let i = 0; i < list.length; i++) {
if (list[i].type == 2) {
list[i].ucMock = JSON.stringify(list[i].ucMock)
} else if (list[i].type == 4) {
let time = {
startTime: list[i].ucMock[0],
endTime: list[i].ucMock[0],
}
list[i].ucMock = JSON.stringify(time)
}
}
return list;
}
function JSONparse(list){
for (let i = 0; i < list.length; i++) {
if (list[i].type == 2) {
list[i].ucMock = JSON.parse(list[i].ucMock)
} else if (list[i].type == 4) {
let time = JSON.parse(list[i].ucMock)
list[i].ucMock = [time.startTime,time.endTime]
}
}
return list;
}
export default {
components: {},
props: [],
data() {
return {
tableHeight: document.documentElement.scrollHeight - 245 + "px",
//
cloumns: [],
queryId: null,
info: {
uqSql: null,
uqName: null,
uqDescribe: null,
},
previewDate:{
open:false,
data:[],
header:[],
},
rules: {
uqName: [{required: true, message: '请输入名称', trigger: 'blur'}],
uqDescribe: [{required: true, message: '请输入描述', trigger: 'blur'}],
},
}
},
computed: {},
watch: {},
created() {
this.queryId = this.$route.params && this.$route.params.queryId;
getQueryInfo(this.queryId).then(res => {
this.cloumns = []
this.info = res.data.info
this.cloumns = JSONparse(res.data.list)
})
},
mounted() {
},
methods: {
/** 预览 */
previewQuery(){
this.$refs['elForm'].validate(valid => {
if (valid) {
let list = JSONString(this.cloumns)
let data = this.info
data.uniCons = list
previewQueryData(data).then(res => {
console.log(res)
this.previewDate.data = res.data
this.previewDate.header = []
for (var key in this.previewDate.data[0]) {
this.previewDate.header.push(key)
}
this.cloumns = JSONparse(list)
})
}else {
return
}
})
},
/** 删除按钮 */
handleDelete(index) {
this.cloumns.splice(index, 1);
},
ucTypeChang(index, row) {
if (row.ucType == 'input' && row.ucName != 'BETWEEN') {
this.cloumns[index].type = 1
this.cloumns[index].ucMock = ''
} else if (row.ucType == 'input' && row.ucName == 'BETWEEN') {
this.cloumns[index].type = 2
this.cloumns[index].ucMock = {
begin: '',
end: '',
}
} else if (row.ucType == 'datetime' && row.ucName != 'BETWEEN') {
this.cloumns[index].type = 3
this.cloumns[index].ucMock = ''
} else if (row.ucType == 'datetime' && row.ucName == 'BETWEEN') {
this.cloumns[index].type = 4
this.cloumns[index].ucMock = []
}
},
/** 添加 */
handleAdd() {
let row = {
id: null,
uqId: this.queryId,
ucName: 'EQ',
ucDescribe: '',
ucKey: '',
ucMock: '',
ucType: 'input',
type: 1,
}
this.cloumns.push(row)
},
submitForm() {
this.$refs['elForm'].validate(valid => {
if (valid) {
let list = JSONString(this.cloumns)
let data = this.info
data.uniCons = list
editQueryInfo(data).then(res => {
console.log(res)
this.cloumns = JSONparse(list)
})
}else {
return
}
})
},
}
}
</script>
<style scoped>
</style>

View File

@ -5,6 +5,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
@ -16,59 +17,54 @@ import org.springframework.stereotype.Component;
*
* @author hchyun
**/
@SuppressWarnings(value = { "unchecked", "rawtypes" })
@SuppressWarnings(value = {"unchecked", "rawtypes"})
@Component
public class RedisCache
{
public class RedisCache {
@Autowired
public RedisTemplate redisTemplate;
/**
* 缓存基本的对象IntegerString实体类等
*
* @param key 缓存的键值
* @param key 缓存的键值
* @param value 缓存的值
*/
public <T> void setCacheObject(final String key, final T value)
{
public <T> void setCacheObject(final String key, final T value) {
redisTemplate.opsForValue().set(key, value);
}
/**
* 缓存基本的对象IntegerString实体类等
*
* @param key 缓存的键值
* @param value 缓存的值
* @param timeout 时间
* @param key 缓存的键值
* @param value 缓存的值
* @param timeout 时间
* @param timeUnit 时间颗粒度
*/
public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit)
{
public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) {
redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
}
/**
* 设置有效时间
*
* @param key Redis键
* @param key Redis键
* @param timeout 超时时间
* @return true=设置成功false=设置失败
*/
public boolean expire(final String key, final long timeout)
{
public boolean expire(final String key, final long timeout) {
return expire(key, timeout, TimeUnit.SECONDS);
}
/**
* 设置有效时间
*
* @param key Redis键
* @param key Redis键
* @param timeout 超时时间
* @param unit 时间单位
* @param unit 时间单位
* @return true=设置成功false=设置失败
*/
public boolean expire(final String key, final long timeout, final TimeUnit unit)
{
public boolean expire(final String key, final long timeout, final TimeUnit unit) {
return redisTemplate.expire(key, timeout, unit);
}
@ -78,8 +74,7 @@ public class RedisCache
* @param key 缓存键值
* @return 缓存键值对应的数据
*/
public <T> T getCacheObject(final String key)
{
public <T> T getCacheObject(final String key) {
ValueOperations<String, T> operation = redisTemplate.opsForValue();
return operation.get(key);
}
@ -89,8 +84,7 @@ public class RedisCache
*
* @param key
*/
public boolean deleteObject(final String key)
{
public boolean deleteObject(final String key) {
return redisTemplate.delete(key);
}
@ -100,20 +94,18 @@ public class RedisCache
* @param collection 多个对象
* @return
*/
public long deleteObject(final Collection collection)
{
public long deleteObject(final Collection collection) {
return redisTemplate.delete(collection);
}
/**
* 缓存List数据
*
* @param key 缓存的键值
* @param key 缓存的键值
* @param dataList 待缓存的List数据
* @return 缓存的对象
*/
public <T> long setCacheList(final String key, final List<T> dataList)
{
public <T> long setCacheList(final String key, final List<T> dataList) {
Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
return count == null ? 0 : count;
}
@ -124,20 +116,18 @@ public class RedisCache
* @param key 缓存的键值
* @return 缓存键值对应的数据
*/
public <T> List<T> getCacheList(final String key)
{
public <T> List<T> getCacheList(final String key) {
return redisTemplate.opsForList().range(key, 0, -1);
}
/**
* 缓存Set
*
* @param key 缓存键值
* @param key 缓存键值
* @param dataSet 缓存的数据
* @return 缓存数据的对象
*/
public <T> long setCacheSet(final String key, final Set<T> dataSet)
{
public <T> long setCacheSet(final String key, final Set<T> dataSet) {
Long count = redisTemplate.opsForSet().add(key, dataSet);
return count == null ? 0 : count;
}
@ -148,8 +138,7 @@ public class RedisCache
* @param key
* @return
*/
public <T> Set<T> getCacheSet(final String key)
{
public <T> Set<T> getCacheSet(final String key) {
return redisTemplate.opsForSet().members(key);
}
@ -159,8 +148,7 @@ public class RedisCache
* @param key
* @param dataMap
*/
public <T> void setCacheMap(final String key, final Map<String, T> dataMap)
{
public <T> void setCacheMap(final String key, final Map<String, T> dataMap) {
if (dataMap != null) {
redisTemplate.opsForHash().putAll(key, dataMap);
}
@ -172,32 +160,29 @@ public class RedisCache
* @param key
* @return
*/
public <T> Map<String, T> getCacheMap(final String key)
{
public <T> Map<String, T> getCacheMap(final String key) {
return redisTemplate.opsForHash().entries(key);
}
/**
* 往Hash中存入数据
*
* @param key Redis键
* @param hKey Hash键
* @param key Redis键
* @param hKey Hash键
* @param value
*/
public <T> void setCacheMapValue(final String key, final String hKey, final T value)
{
public <T> void setCacheMapValue(final String key, final String hKey, final T value) {
redisTemplate.opsForHash().put(key, hKey, value);
}
/**
* 获取Hash中的数据
*
* @param key Redis键
* @param key Redis键
* @param hKey Hash键
* @return Hash中的对象
*/
public <T> T getCacheMapValue(final String key, final String hKey)
{
public <T> T getCacheMapValue(final String key, final String hKey) {
HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
return opsForHash.get(key, hKey);
}
@ -205,12 +190,11 @@ public class RedisCache
/**
* 获取多个Hash中的数据
*
* @param key Redis键
* @param key Redis键
* @param hKeys Hash键集合
* @return Hash对象集合
*/
public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys)
{
public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys) {
return redisTemplate.opsForHash().multiGet(key, hKeys);
}
@ -220,8 +204,7 @@ public class RedisCache
* @param pattern 字符串前缀
* @return 对象列表
*/
public Collection<String> keys(final String pattern)
{
public Collection<String> keys(final String pattern) {
return redisTemplate.keys(pattern);
}
}

View File

@ -110,7 +110,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/webjars/**").anonymous()
.antMatchers("/*/api-docs").anonymous()
.antMatchers("/druid/**").anonymous()
.antMatchers("/test/**").anonymous()
.antMatchers("/tests/**").anonymous()
// 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated()
.and()

View File

@ -1,6 +1,7 @@
package com.hchyun.framework.web.service;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;
@ -20,12 +21,11 @@ import com.hchyun.framework.dao.factory.AsyncFactory;
/**
* 登录校验方法
*
*
* @author hchyun
*/
@Component
public class SysLoginService
{
public class SysLoginService {
@Autowired
private TokenService tokenService;
@ -37,45 +37,36 @@ public class SysLoginService
/**
* 登录验证
*
*
* @param username 用户名
* @param password 密码
* @param code 验证码
* @param uuid 唯一标识
* @param code 验证码
* @param uuid 唯一标识
* @return 结果
*/
public String login(String username, String password, String code, String uuid)
{
public String login(String username, String password, String code, String uuid) {
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
String captcha = redisCache.getCacheObject(verifyKey);
redisCache.deleteObject(verifyKey);
if (captcha == null)
{
if (captcha == null) {
AsyncDao.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
throw new CaptchaExpireException();
}
if (!code.equalsIgnoreCase(captcha))
{
if (!code.equalsIgnoreCase(captcha)) {
AsyncDao.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
throw new CaptchaException();
}
// 用户验证
Authentication authentication = null;
try
{
try {
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
authentication = authenticationManager
.authenticate(new UsernamePasswordAuthenticationToken(username, password));
}
catch (Exception e)
{
if (e instanceof BadCredentialsException)
{
} catch (Exception e) {
if (e instanceof BadCredentialsException) {
AsyncDao.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
throw new UserPasswordNotMatchException();
}
else
{
} else {
AsyncDao.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
throw new CustomException(e.getMessage());
}

View File

@ -0,0 +1,113 @@
package com.hchyun.generator.controller;
import com.hchyun.common.constant.ReturnConstants;
import com.hchyun.common.core.entity.AjaxResult;
import com.hchyun.common.utils.ServerResult;
import com.hchyun.generator.entity.UniCon;
import com.hchyun.generator.entity.UniQuery;
import com.hchyun.generator.service.QueryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author 18209
* @Date 2021/1/30 18:25
* @Version 1.0
*/
@RestController
@RequestMapping("/query")
public class QueryController {
protected final Logger logger = LoggerFactory.getLogger(QueryController.class);
@Autowired
private QueryService queryService;
@PreAuthorize("@ss.hasPermi('query:list')")
@GetMapping("/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id){
try {
ServerResult<UniQuery> serverResult = queryService.selectQueryById(id);
if (serverResult.isStart()){
UniQuery uniQuery = serverResult.getData();
Map<String,Object> modeMap = new HashMap<String, Object>();
List<UniCon> uniCons = uniQuery.getUniCons();
uniQuery.setUniCons(null);
modeMap.put("info",uniQuery);
modeMap.put("list",uniCons);
return AjaxResult.success(modeMap);
}else {
return AjaxResult.error(serverResult.getMsg());
}
}catch (RuntimeException e){
logger.error(e.getMessage());
return AjaxResult.error(ReturnConstants.SYS_ERROR);
}
}
// @PreAuthorize("@ss.hasPermi('query:list')")
// @GetMapping("/list")
// public AjaxResult list(UniQuery uniQuery){
// try {
// return AjaxResult.success();
// }catch (RuntimeException e){
// logger.error(e.getMessage());
// return AjaxResult.error(ReturnConstants.SYS_ERROR);
// }
// }
@PreAuthorize("@ss.hasPermi('query:edit')")
@PutMapping
public AjaxResult edit(@Validated @RequestBody UniQuery uniQuery){
try {
ServerResult serverResult = queryService.updateQueryInfo(uniQuery);
if (serverResult.isStart()){
return AjaxResult.success();
}else {
return AjaxResult.error(serverResult.getMsg());
}
}catch (RuntimeException e){
logger.error(e.getMessage());
return AjaxResult.error(ReturnConstants.SYS_ERROR);
}
}
@PreAuthorize("@ss.hasPermi('query:preview')")
@PutMapping("preview")
public AjaxResult Preview(@Validated @RequestBody UniQuery uniQuery){
try {
ServerResult<List<Map<String,Object>>> serverResult = queryService.previewQuery(uniQuery);
if (serverResult.isStart()){
return AjaxResult.success(serverResult.getData());
}else {
return AjaxResult.error(serverResult.getMsg());
}
}catch (RuntimeException e){
logger.error(e.getMessage());
return AjaxResult.error(ReturnConstants.SYS_ERROR);
}
}
@PreAuthorize("@ss.hasPermi('query:edit')")
@GetMapping("/export/{id}")
public AjaxResult Export(@PathVariable("id") Long id){
try {
return AjaxResult.success();
}catch (RuntimeException e){
logger.error(e.getMessage());
return AjaxResult.error(ReturnConstants.SYS_ERROR);
}
}
}

View File

@ -14,7 +14,7 @@ import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/test")
@RequestMapping("/tests")
public class SysTest {
@Autowired
private InterTableDao interTableDao;

View File

@ -0,0 +1,192 @@
package com.hchyun.generator.controller;
import java.io.Serializable;
import java.util.List;
import com.hchyun.common.constant.ReturnConstants;
import com.hchyun.common.core.controller.HcyBaseController;
import com.hchyun.common.utils.ServerResult;
import com.hchyun.common.utils.poi.ExcelUtil;
import com.hchyun.generator.entity.UniQuery;
import com.hchyun.generator.service.UniQueryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hchyun.common.annotation.Log;
import com.hchyun.common.core.entity.AjaxResult;
import com.hchyun.common.enums.BusinessType;
/**
* 万能查询Controller
*
* @author hchyun
* @date 2021-01-30
*/
@Api(value = "万能查询管理",tags = "万能查询管理")
@RestController
@RequestMapping("/tool/query")
public class UniQueryController extends HcyBaseController {
protected final Logger logger = LoggerFactory.getLogger(UniQueryController.class);
@Autowired
private UniQueryService uniQueryService;
/**
* 查询万能查询列表
*/
@ApiOperation("查询万能查询列表")
@PreAuthorize("@ss.hasPermi('tool:query:list')")
@GetMapping("/list")
public Serializable list(UniQuery uniQuery) {
try {
startPage();
ServerResult<List<UniQuery>> serverResult = uniQueryService.selectUniQueryList(uniQuery);
if (serverResult.isStart()) {
return getDataTable(serverResult.getData());
} else {
return AjaxResult.info(serverResult.getMsg());
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
return AjaxResult.error(ReturnConstants.SYS_ERROR);
}
}
/**
* 导出万能查询列表
*/
@ApiOperation("导出万能查询列表")
@PreAuthorize("@ss.hasPermi('tool:query:export')")
@Log(title = "万能查询", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(UniQuery uniQuery) {
try {
ServerResult<List<UniQuery>> serverResult = uniQueryService.selectUniQueryList(uniQuery);
ExcelUtil<UniQuery> util = new ExcelUtil<UniQuery>(UniQuery. class);
if (serverResult.isStart()) {
return util.exportExcel(serverResult.getData(), "query");
} else {
return AjaxResult.error(serverResult.getMsg());
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
return AjaxResult.error(ReturnConstants.SYS_ERROR);
}
}
/**
* 获取万能查询详细信息
*/
@ApiOperation("获取万能查询详细信息")
@ApiImplicitParam(name = "id" , value = "万能查询id" , required = true, dataType = "Long" , paramType = "path")
@PreAuthorize("@ss.hasPermi('tool:query:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
try {
ServerResult<UniQuery> serverResult = uniQueryService.selectUniQueryById(id);
if (serverResult.isStart()) {
return AjaxResult.success(serverResult.getData());
} else {
return AjaxResult.info(serverResult.getMsg());
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
return AjaxResult.error(ReturnConstants.SYS_ERROR);
}
}
/**
* 新增万能查询
*/
@ApiOperation("新增万能查询")
@ApiImplicitParam(name = "uniQuery" , value = "新增万能查询信息" , dataType = "UniQuery")
@PreAuthorize("@ss.hasPermi('tool:query:add')")
@Log(title = "万能查询", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody UniQuery uniQuery) {
if (uniQuery.getUqName() == null || uniQuery.getUqName().equals("")) {
return AjaxResult.error("名称不能为空!");
}
if (uniQuery.getUqDescribe() == null || uniQuery.getUqDescribe().equals("")) {
return AjaxResult.error("描述不能为空!");
}
try {
ServerResult<Integer> serverResult = uniQueryService.insertUniQuery(uniQuery);
if (serverResult.isStart()) {
return AjaxResult.success();
} else {
return AjaxResult.error(serverResult.getMsg());
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
return AjaxResult.error(ReturnConstants.SYS_ERROR);
}
}
/**
* 修改万能查询
*/
@ApiOperation("修改万能查询")
@ApiImplicitParam(name = "uniQuery" , value = "修改万能查询信息" , dataType = "UniQuery")
@PreAuthorize("@ss.hasPermi('tool:query:edit')")
@Log(title = "万能查询", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody UniQuery uniQuery) {
try {
if (uniQuery.getUqName() == null || uniQuery.getUqName().equals("")) {
return AjaxResult.error("名称不能为空!");
}
if (uniQuery.getUqDescribe() == null || uniQuery.getUqDescribe().equals("")) {
return AjaxResult.error("描述不能为空!");
}
ServerResult<Integer> serverResult = uniQueryService.updateUniQuery(uniQuery);
if (serverResult.isStart()) {
return AjaxResult.success();
} else {
return AjaxResult.error(serverResult.getMsg());
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
return AjaxResult.error(ReturnConstants.SYS_ERROR);
}
}
/**
* 删除万能查询
*/
@ApiOperation("删除万能查询")
@ApiImplicitParam(name = "ids" , value = "万能查询ids" , required = true, dataType = "Long" , paramType = "path")
@PreAuthorize("@ss.hasPermi('tool:query:remove')")
@Log(title = "万能查询", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
try {
if (ids.length<0){
return AjaxResult.error("id不能为空!");
}
ServerResult<Integer> serverResult = uniQueryService.deleteUniQueryByIds(ids);
if (serverResult.isStart()) {
return AjaxResult.success();
} else {
return AjaxResult.error(serverResult.getMsg());
}
}catch (RuntimeException e){
logger.error(e.getMessage());
return AjaxResult.error(ReturnConstants.SYS_ERROR);
}
}
}

View File

@ -0,0 +1,26 @@
package com.hchyun.generator.dao;
import com.hchyun.generator.entity.UniCon;
import com.hchyun.generator.entity.UniQuery;
import java.util.List;
import java.util.Map;
/**
* @Author 18209
* @Date 2021/1/30 18:52
* @Version 1.0
*/
public interface QueryDao {
UniQuery selectQueryInfo(Long id);
Integer updateQueryInfo(UniQuery uniQuery);
Integer deleteUniCon(Long uqId);
Integer insertUniCon(List<UniCon> uniCons);
List<Map<String,Object>> UniQuery(String paramSQL);
}

View File

@ -0,0 +1,68 @@
package com.hchyun.generator.dao;
import com.hchyun.generator.entity.UniQuery;
import java.util.List;
/**
* 万能查询Mapper接口
*
* @author hchyun
* @date 2021-01-30
*/
public interface UniQueryDao
{
/**
* 查询万能查询
*
* @param id 万能查询ID
* @return 万能查询
*/
UniQuery selectUniQueryById(Long id);
/**
* 查询万能查询列表
*
* @param uniQuery 万能查询
* @return 万能查询集合
*/
List<UniQuery> selectUniQueryList(UniQuery uniQuery);
/**
* 新增万能查询
*
* @param uniQuery 万能查询
* @return 结果
*/
int insertUniQuery(UniQuery uniQuery);
/**
* 修改万能查询
*
* @param uniQuery 万能查询
* @return 结果
*/
int updateUniQuery(UniQuery uniQuery);
/**
* 删除万能查询
*
* @param id 万能查询ID
* @return 结果
*/
int deleteUniQueryById(Long id);
/**
* 批量删除万能查询
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteUniQueryByIds(Long[] ids);
}

View File

@ -0,0 +1,127 @@
package com.hchyun.generator.entity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 万能查询条件对象 sys_uni_con
*
* @author hchyun
* @date 2021-01-30
*/
public class UniCon {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Long id;
/**
* 万能查询tableid
*/
private Long uqId;
/**
* 名称(lable)
*/
private String ucName;
/**
* 关键字
*/
private String ucKey;
/**
* 查询条件
*/
private String ucCon;
/**
* 模拟数据
*/
private String ucMock;
/**
* 描述
*/
private String ucDescribe;
/** 输入类型 */
private String ucType;
/** 显示类型 */
private Integer type;
public String getUcType() {
return ucType;
}
public void setUcType(String ucType) {
this.ucType = ucType;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setUqId(Long uqId) {
this.uqId = uqId;
}
public Long getUqId() {
return uqId;
}
public void setUcName(String ucName) {
this.ucName = ucName;
}
public String getUcName() {
return ucName;
}
public void setUcKey(String ucKey) {
this.ucKey = ucKey;
}
public String getUcKey() {
return ucKey;
}
public void setUcCon(String ucCon) {
this.ucCon = ucCon;
}
public String getUcCon() {
return ucCon;
}
public String getUcMock() {
return ucMock;
}
public void setUcMock(String ucMock) {
this.ucMock = ucMock;
}
public String getUcDescribe() {
return ucDescribe;
}
public void setUcDescribe(String ucDescribe) {
this.ucDescribe = ucDescribe;
}
}

View File

@ -0,0 +1,93 @@
package com.hchyun.generator.entity;
import com.hchyun.common.core.entity.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.List;
/**
* 万能查询对象 sys_uni_query
*
* @author hchyun
* @date 2021-01-30
*/
public class UniQuery extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Long id;
/**
* 名称
*/
private String uqName;
/**
* sql语句
*/
private String uqSql;
/**
* 描述
*/
private String uqDescribe;
private List<UniCon> uniCons;
public List<UniCon> getUniCons() {
return uniCons;
}
public void setUniCons(List<UniCon> uniCons) {
this.uniCons = uniCons;
}
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setUqName(String uqName) {
this.uqName = uqName;
}
public String getUqName() {
return uqName;
}
public void setUqSql(String uqSql) {
this.uqSql = uqSql;
}
public String getUqSql() {
return uqSql;
}
public void setUqDescribe(String uqDescribe) {
this.uqDescribe = uqDescribe;
}
public String getUqDescribe() {
return uqDescribe;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("uqName", getUqName())
.append("uqSql", getUqSql())
.append("uqDescribe", getUqDescribe())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,35 @@
package com.hchyun.generator.service;
import com.hchyun.common.utils.ServerResult;
import com.hchyun.generator.entity.UniQuery;
import java.util.List;
import java.util.Map;
/**
* @Author 18209
* @Date 2021/1/30 18:54
* @Version 1.0
*/
public interface QueryService {
/**
* 通过id查询基础信息
* @param id
* @return
*/
ServerResult<UniQuery> selectQueryById(Long id);
/**
* 修改基础信息
* @param uniQuery
* @return
*/
ServerResult updateQueryInfo(UniQuery uniQuery);
/**
* 预览万能查询数据
* @param uniQuery
* @return
*/
ServerResult<List<Map<String,Object>>> previewQuery(UniQuery uniQuery);
}

View File

@ -0,0 +1,63 @@
package com.hchyun.generator.service;
import java.util.List;
import com.hchyun.common.utils.ServerResult;
import com.hchyun.generator.entity.UniQuery;
/**
* 万能查询Service接口
*
* @author hchyun
* @date 2021-01-30
*/
public interface UniQueryService
{
/**
* 查询万能查询
*
* @param id 万能查询ID
* @return 万能查询
*/
ServerResult<UniQuery> selectUniQueryById(Long id);
/**
* 查询万能查询列表
*
* @param uniQuery 万能查询
* @return 万能查询集合
*/
ServerResult<List<UniQuery>> selectUniQueryList(UniQuery uniQuery);
/**
* 新增万能查询
*
* @param uniQuery 万能查询
* @return 结果
*/
ServerResult<Integer> insertUniQuery(UniQuery uniQuery);
/**
* 修改万能查询
*
* @param uniQuery 万能查询
* @return 结果
*/
ServerResult<Integer> updateUniQuery(UniQuery uniQuery);
/**
* 批量删除万能查询
*
* @param ids 需要删除的万能查询ID
* @return 结果
*/
ServerResult<Integer> deleteUniQueryByIds(Long[] ids);
/**
* 删除万能查询信息
*
* @param id 万能查询ID
* @return 结果
*/
ServerResult<Integer> deleteUniQueryById(Long id);
}

View File

@ -0,0 +1,76 @@
package com.hchyun.generator.service.impl;
import com.hchyun.common.constant.ReturnConstants;
import com.hchyun.common.utils.ServerResult;
import com.hchyun.generator.dao.QueryDao;
import com.hchyun.generator.dao.UniQueryDao;
import com.hchyun.generator.entity.UniQuery;
import com.hchyun.generator.service.QueryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
* @Author 18209
* @Date 2021/1/30 18:54
* @Version 1.0
*/
@Service
public class QueryServiceImpl implements QueryService {
private Logger logger = LoggerFactory.getLogger(QueryServiceImpl.class);
@Autowired
private QueryDao queryDao;
@Autowired
private UniQueryDao uniQueryDao;
@Override
public ServerResult<UniQuery> selectQueryById(Long id) {
try {
UniQuery uniQuery = queryDao.selectQueryInfo(id);
if (uniQuery != null) {
return new ServerResult<UniQuery>(true, uniQuery);
} else {
return new ServerResult<UniQuery>(false, ReturnConstants.RESULT_EMPTY);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
return new ServerResult<UniQuery>(false, ReturnConstants.SYS_FAILL);
}
}
@Override
@Transactional
public ServerResult updateQueryInfo(UniQuery uniQuery) {
try {
Integer uqrenewal = uniQueryDao.updateUniQuery(uniQuery);
if (uqrenewal > 0) {
queryDao.deleteUniCon(uniQuery.getId());
Integer ucrenewal = queryDao.insertUniCon(uniQuery.getUniCons());
if (ucrenewal>0){
return new ServerResult(true);
}
}
return new ServerResult(false,"操作失败!");
} catch (RuntimeException e) {
logger.error(e.getMessage());
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
}
}
@Override
public ServerResult<List<Map<String,Object>>> previewQuery(UniQuery uniQuery) {
try {
List<Map<String,Object>> dataMap = queryDao.UniQuery(uniQuery.getUqSql());
return new ServerResult<List<Map<String,Object>>>(true,dataMap);
}catch (RuntimeException e){
logger.error(e.getMessage());
return new ServerResult<List<Map<String,Object>>>(false,e.getMessage());
}
}
}

View File

@ -0,0 +1,156 @@
package com.hchyun.generator.service.impl;
import java.util.List;
import com.hchyun.common.constant.ReturnConstants;
import com.hchyun.common.utils.SecurityUtils;
import com.hchyun.common.utils.ServerResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hchyun.generator.dao.UniQueryDao;
import com.hchyun.generator.entity.UniQuery;
import com.hchyun.generator.service.UniQueryService;
/**
* 万能查询Service业务层处理
*
* @author hchyun
* @date 2021-01-30
*/
@Service
public class UniQueryServiceImpl implements UniQueryService {
private Logger logger = LoggerFactory.getLogger(UniQueryServiceImpl.class);
@Autowired
private UniQueryDao uniQueryDao;
/**
* 查询万能查询
*
* @param id 万能查询ID
* @return 万能查询
*/
@Override
public ServerResult<UniQuery> selectUniQueryById(Long id) {
try {
UniQuery uniQuery = uniQueryDao.selectUniQueryById(id);
if (uniQuery != null){
return new ServerResult<UniQuery>(true,uniQuery);
}else {
return new ServerResult<UniQuery>(false, ReturnConstants.RESULT_EMPTY);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
return new ServerResult<UniQuery>(false,ReturnConstants.DB_EX);
}
}
/**
* 查询万能查询列表
*
* @param uniQuery 万能查询
* @return 万能查询
*/
@Override
public ServerResult<List<UniQuery>> selectUniQueryList(UniQuery uniQuery) {
try {
List<UniQuery> uniQueryList = uniQueryDao.selectUniQueryList(uniQuery);
if (uniQueryList.size()>0){
return new ServerResult<List<UniQuery>>(true,uniQueryList);
}else {
return new ServerResult<List<UniQuery>>(false,ReturnConstants.RESULT_EMPTY);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
return new ServerResult<List<UniQuery>>(false,ReturnConstants.DB_EX);
}
}
/**
* 新增万能查询
*
* @param uniQuery 万能查询
* @return 结果
*/
@Override
public ServerResult<Integer> insertUniQuery(UniQuery uniQuery) {
try {
uniQuery.setCreateBy(SecurityUtils.getUserId());
Integer renewal = uniQueryDao.insertUniQuery(uniQuery);
if (renewal >0){
return new ServerResult<Integer>(true,renewal);
}else {
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
}
}
/**
* 修改万能查询
*
* @param uniQuery 万能查询
* @return 结果
*/
@Override
public ServerResult<Integer> updateUniQuery(UniQuery uniQuery) {
try {
uniQuery.setUpdateBy(SecurityUtils.getUserId());
Integer renewal = uniQueryDao.updateUniQuery(uniQuery);
if (renewal >0){
return new ServerResult<Integer>(true,renewal);
}else {
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
}
}
/**
* 批量删除万能查询
*
* @param ids 需要删除的万能查询ID
* @return 结果
*/
@Override
public ServerResult<Integer> deleteUniQueryByIds(Long[] ids) {
try {
Integer renewal = uniQueryDao.deleteUniQueryByIds(ids);
if (renewal >0){
return new ServerResult<Integer>(true,renewal);
}else {
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
}
}
/**
* 删除万能查询信息
*
* @param id 万能查询ID
* @return 结果
*/
@Override
public ServerResult<Integer> deleteUniQueryById(Long id) {
try {
Integer renewal = uniQueryDao.deleteUniQueryById(id);
if (renewal >0){
return new ServerResult<Integer>(true,renewal);
}else {
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
}
}catch (RuntimeException e){
logger.error(e.getMessage());
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
}
}
}

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hchyun.generator.dao.QueryDao">
<resultMap type="com.hchyun.generator.entity.UniQuery" id="QueryResult">
<result property="id" column="id" />
<result property="uqName" column="uq_name" />
<result property="uqSql" column="uq_sql" />
<result property="uqDescribe" column="uq_describe" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<collection property="uniCons" javaType="java.util.List" notNullColumn="id" resultMap="UniConResult"/>
</resultMap>
<resultMap type="com.hchyun.generator.entity.UniCon" id="UniConResult">
<result property="id" column="uc_id" />
<result property="uqId" column="uq_id" />
<result property="ucName" column="uc_name" />
<result property="ucKey" column="uc_key" />
<result property="ucCon" column="uc_con" />
<result property="ucMock" column="uc_mock" />
<result property="ucDescribe" column="uc_describe" />
<result property="ucType" column="uc_type" />
<result property="type" column="type" />
</resultMap>
<select id="UniQuery" resultType="java.util.HashMap">
${paramSQL}
</select>
<select id="selectQueryInfo" parameterType="Long" resultMap="QueryResult">
select uq.id, uq.uq_name, uq.uq_sql, uq.uq_describe, uq.create_by, uq.create_time, uq.update_by, uq.update_time,
uc.id as uc_id, uc.uq_id, uc.uc_name, uc.uc_key, uc.uc_con, uc.uc_mock, uc.uc_describe ,uc.uc_type,uc.type
from sys_uni_query uq
left join sys_uni_con uc on uc.uq_id = uq.id
where uq.id = #{id}
</select>
<delete id="deleteUniCon">
delete from sys_uni_con where uq_id = #{uqId}
</delete>
<insert id="insertUniCon">
insert into sys_uni_con(uq_id,uc_name,uc_key,uc_con,uc_mock,uc_describe,uc_type,type) values
<foreach item="item" index="index" collection="list" separator=",">
(#{item.uqId},#{item.ucName},#{item.ucKey},#{item.ucCon},#{item.ucMock},#{item.ucDescribe},#{item.ucType},#{item.type})
</foreach>
</insert>
</mapper>

View File

@ -26,6 +26,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
#if($Permission)
@Api(value = "${functionName}",tags = "${functionName}")
#end

View File

@ -3,6 +3,7 @@ package com.hchyun.system.service.impl;
import java.util.Collection;
import java.util.List;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hchyun.common.annotation.DataSource;
@ -19,12 +20,11 @@ import com.hchyun.system.service.ISysConfigService;
/**
* 参数配置 服务层实现
*
*
* @author hchyun
*/
@Service
public class SysConfigServiceImpl implements ISysConfigService
{
public class SysConfigServiceImpl implements ISysConfigService {
@Autowired
private SysConfigDao configMapper;
@ -35,25 +35,22 @@ public class SysConfigServiceImpl implements ISysConfigService
* 项目启动时初始化参数到缓存
*/
@PostConstruct
public void init()
{
public void init() {
List<SysConfig> configsList = configMapper.selectConfigList(new SysConfig());
for (SysConfig config : configsList)
{
for (SysConfig config : configsList) {
redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
}
}
/**
* 查询参数配置信息
*
*
* @param configId 参数配置ID
* @return 参数配置信息
*/
@Override
@DataSource(DataSourceType.MASTER)
public SysConfig selectConfigById(Long configId)
{
public SysConfig selectConfigById(Long configId) {
SysConfig config = new SysConfig();
config.setConfigId(configId);
return configMapper.selectConfig(config);
@ -61,23 +58,20 @@ public class SysConfigServiceImpl implements ISysConfigService
/**
* 根据键名查询参数配置信息
*
*
* @param configKey 参数key
* @return 参数键值
*/
@Override
public String selectConfigByKey(String configKey)
{
public String selectConfigByKey(String configKey) {
String configValue = Convert.toStr(redisCache.getCacheObject(getCacheKey(configKey)));
if (StringUtils.isNotEmpty(configValue))
{
if (StringUtils.isNotEmpty(configValue)) {
return configValue;
}
SysConfig config = new SysConfig();
config.setConfigKey(configKey);
SysConfig retConfig = configMapper.selectConfig(config);
if (StringUtils.isNotNull(retConfig))
{
if (StringUtils.isNotNull(retConfig)) {
redisCache.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue());
return retConfig.getConfigValue();
}
@ -86,28 +80,25 @@ public class SysConfigServiceImpl implements ISysConfigService
/**
* 查询参数配置列表
*
*
* @param config 参数配置信息
* @return 参数配置集合
*/
@Override
public List<SysConfig> selectConfigList(SysConfig config)
{
public List<SysConfig> selectConfigList(SysConfig config) {
return configMapper.selectConfigList(config);
}
/**
* 新增参数配置
*
*
* @param config 参数配置信息
* @return 结果
*/
@Override
public int insertConfig(SysConfig config)
{
public int insertConfig(SysConfig config) {
int row = configMapper.insertConfig(config);
if (row > 0)
{
if (row > 0) {
redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
}
return row;
@ -115,16 +106,14 @@ public class SysConfigServiceImpl implements ISysConfigService
/**
* 修改参数配置
*
*
* @param config 参数配置信息
* @return 结果
*/
@Override
public int updateConfig(SysConfig config)
{
public int updateConfig(SysConfig config) {
int row = configMapper.updateConfig(config);
if (row > 0)
{
if (row > 0) {
redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
}
return row;
@ -132,24 +121,20 @@ public class SysConfigServiceImpl implements ISysConfigService
/**
* 批量删除参数信息
*
*
* @param configIds 需要删除的参数ID
* @return 结果
*/
@Override
public int deleteConfigByIds(Long[] configIds)
{
for (Long configId : configIds)
{
public int deleteConfigByIds(Long[] configIds) {
for (Long configId : configIds) {
SysConfig config = selectConfigById(configId);
if (StringUtils.equals(UserConstants.YES, config.getConfigType()))
{
if (StringUtils.equals(UserConstants.YES, config.getConfigType())) {
throw new CustomException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey()));
}
}
int count = configMapper.deleteConfigByIds(configIds);
if (count > 0)
{
if (count > 0) {
Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*");
redisCache.deleteObject(keys);
}
@ -160,25 +145,22 @@ public class SysConfigServiceImpl implements ISysConfigService
* 清空缓存数据
*/
@Override
public void clearCache()
{
public void clearCache() {
Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*");
redisCache.deleteObject(keys);
}
/**
* 校验参数键名是否唯一
*
*
* @param config 参数配置信息
* @return 结果
*/
@Override
public String checkConfigKeyUnique(SysConfig config)
{
public String checkConfigKeyUnique(SysConfig config) {
Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId();
SysConfig info = configMapper.checkConfigKeyUnique(config.getConfigKey());
if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue())
{
if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
@ -186,12 +168,11 @@ public class SysConfigServiceImpl implements ISysConfigService
/**
* 设置cache key
*
*
* @param configKey 参数键
* @return 缓存键key
*/
private String getCacheKey(String configKey)
{
private String getCacheKey(String configKey) {
return Constants.SYS_CONFIG_KEY + configKey;
}
}

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hchyun.generator.dao.UniQueryDao">
<resultMap type="com.hchyun.generator.entity.UniQuery" id="UniQueryResult">
<result property="id" column="id" />
<result property="uqName" column="uq_name" />
<result property="uqSql" column="uq_sql" />
<result property="uqDescribe" column="uq_describe" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectUniQueryVo">
select id, uq_name, uq_sql, uq_describe, create_by, create_time, update_by, update_time from sys_uni_query
</sql>
<select id="selectUniQueryList" parameterType="UniQuery" resultMap="UniQueryResult">
<include refid="selectUniQueryVo"/>
<where>
<if test="uqName != null and uqName != ''"> and uq_name like concat('%', #{uqName}, '%')</if>
<if test="uqDescribe != null and uqDescribe != ''"> and uq_describe like concat('%', #{uqDescribe}, '%')</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
</where>
</select>
<select id="selectUniQueryById" parameterType="Long" resultMap="UniQueryResult">
<include refid="selectUniQueryVo"/>
where id = #{id}
</select>
<insert id="insertUniQuery" parameterType="UniQuery" useGeneratedKeys="true" keyProperty="id">
insert into sys_uni_query
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="uqName != null and uqName != ''">uq_name,</if>
<if test="uqSql != null">uq_sql,</if>
<if test="uqDescribe != null and uqDescribe != ''">uq_describe,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="uqName != null and uqName != ''">#{uqName},</if>
<if test="uqSql != null">#{uqSql},</if>
<if test="uqDescribe != null and uqDescribe != ''">#{uqDescribe},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim>
</insert>
<update id="updateUniQuery" parameterType="UniQuery">
update sys_uni_query
<trim prefix="SET" suffixOverrides=",">
<if test="uqName != null and uqName != ''">uq_name = #{uqName},</if>
<if test="uqSql != null">uq_sql = #{uqSql},</if>
<if test="uqDescribe != null and uqDescribe != ''">uq_describe = #{uqDescribe},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteUniQueryById" parameterType="Long">
delete from sys_uni_query where id = #{id}
</delete>
<delete id="deleteUniQueryByIds" parameterType="String">
delete from sys_uni_query where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,27 @@
package com.hchyun.test.controller;
import com.hchyun.test.dao.ResultsDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
* @Author 18209
* @Date 2021/1/29 17:36
* @Version 1.0
*/
@RestController
@RequestMapping("/test")
public class Test {
@Autowired
private ResultsDao resultsDao;
@GetMapping("/map")
public List<Map<String,Object>> mapTest(){
return resultsDao.testMap();
}
}

View File

@ -1,19 +1,20 @@
package com.hchyun.test.dao;
import java.util.List;
import java.util.Map;
import com.hchyun.test.entity.Results;
/**
* 成绩Mapper接口
*
*
* @author hchyun
* @date 2021-01-24
*/
public interface ResultsDao
{
public interface ResultsDao {
/**
* 查询成绩
*
*
* @param id 成绩ID
* @return 成绩
*/
@ -21,7 +22,7 @@ public interface ResultsDao
/**
* 查询成绩列表
*
*
* @param results 成绩
* @return 成绩集合
*/
@ -29,7 +30,7 @@ public interface ResultsDao
/**
* 新增成绩
*
*
* @param results 成绩
* @return 结果
*/
@ -37,7 +38,7 @@ public interface ResultsDao
/**
* 修改成绩
*
*
* @param results 成绩
* @return 结果
*/
@ -45,7 +46,7 @@ public interface ResultsDao
/**
* 删除成绩
*
*
* @param id 成绩ID
* @return 结果
*/
@ -53,9 +54,11 @@ public interface ResultsDao
/**
* 批量删除成绩
*
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteResultsByIds(Long[] ids);
List<Map<String,Object>> testMap();
}

View File

@ -16,6 +16,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select id, s_id, java, images, file from sys_results
</sql>
<select id="testMap" resultType="java.util.HashMap">
select * from sys_menu
</select>
<select id="selectResultsList" parameterType="Results" resultMap="ResultsResult">
<include refid="selectResultsVo"/>
<where>