This commit is contained in:
parent
4db542232c
commit
60a78b7341
|
|
@ -0,0 +1,53 @@
|
||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询成绩列表
|
||||||
|
export function listResults(query) {
|
||||||
|
return request({
|
||||||
|
url: '/test/results/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询成绩详细
|
||||||
|
export function getResults(id) {
|
||||||
|
return request({
|
||||||
|
url: '/test/results/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增成绩
|
||||||
|
export function addResults(data) {
|
||||||
|
return request({
|
||||||
|
url: '/test/results',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改成绩
|
||||||
|
export function updateResults(data) {
|
||||||
|
return request({
|
||||||
|
url: '/test/results',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除成绩
|
||||||
|
export function delResults(id) {
|
||||||
|
return request({
|
||||||
|
url: '/test/results/' + id,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出成绩
|
||||||
|
export function exportResults(query) {
|
||||||
|
return request({
|
||||||
|
url: '/test/results/export',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,179 @@
|
||||||
|
<template>
|
||||||
|
<div class="upload-file">
|
||||||
|
<el-upload
|
||||||
|
:action="uploadFileUrl"
|
||||||
|
:before-upload="handleBeforeUpload"
|
||||||
|
:file-list="fileList"
|
||||||
|
:limit="1"
|
||||||
|
:on-error="handleUploadError"
|
||||||
|
:on-exceed="handleExceed"
|
||||||
|
:on-success="handleUploadSuccess"
|
||||||
|
:show-file-list="false"
|
||||||
|
:headers="headers"
|
||||||
|
class="upload-file-uploader"
|
||||||
|
ref="upload"
|
||||||
|
>
|
||||||
|
<!-- 上传按钮 -->
|
||||||
|
<el-button size="mini" type="primary">选取文件</el-button>
|
||||||
|
<!-- 上传提示 -->
|
||||||
|
<div class="el-upload__tip" slot="tip" v-if="showTip">
|
||||||
|
请上传
|
||||||
|
<template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
|
||||||
|
<template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
|
||||||
|
的文件
|
||||||
|
</div>
|
||||||
|
</el-upload>
|
||||||
|
|
||||||
|
<!-- 文件列表 -->
|
||||||
|
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
|
||||||
|
<li :key="file.uid" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in list">
|
||||||
|
<el-link :href="file.url" :underline="false" target="_blank">
|
||||||
|
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
|
||||||
|
</el-link>
|
||||||
|
<div class="ele-upload-list__item-content-action">
|
||||||
|
<el-link :underline="false" @click="handleDelete(index)" type="danger">删除</el-link>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</transition-group>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getToken } from "@/utils/auth";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
// 值
|
||||||
|
value: [String, Object, Array],
|
||||||
|
// 大小限制(MB)
|
||||||
|
fileSize: {
|
||||||
|
type: Number,
|
||||||
|
default: 5,
|
||||||
|
},
|
||||||
|
// 文件类型, 例如['png', 'jpg', 'jpeg']
|
||||||
|
fileType: {
|
||||||
|
type: Array,
|
||||||
|
default: () => ["doc", "xls", "ppt", "txt", "pdf"],
|
||||||
|
},
|
||||||
|
// 是否显示提示
|
||||||
|
isShowTip: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址
|
||||||
|
headers: {
|
||||||
|
Authorization: "Bearer " + getToken(),
|
||||||
|
},
|
||||||
|
fileList: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
// 是否显示提示
|
||||||
|
showTip() {
|
||||||
|
return this.isShowTip && (this.fileType || this.fileSize);
|
||||||
|
},
|
||||||
|
// 列表
|
||||||
|
list() {
|
||||||
|
let temp = 1;
|
||||||
|
if (this.value) {
|
||||||
|
// 首先将值转为数组
|
||||||
|
const list = Array.isArray(this.value) ? this.value : [this.value];
|
||||||
|
// 然后将数组转为对象数组
|
||||||
|
return list.map((item) => {
|
||||||
|
if (typeof item === "string") {
|
||||||
|
item = { name: item, url: item };
|
||||||
|
}
|
||||||
|
item.uid = item.uid || new Date().getTime() + temp++;
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.fileList = [];
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 上传前校检格式和大小
|
||||||
|
handleBeforeUpload(file) {
|
||||||
|
// 校检文件类型
|
||||||
|
if (this.fileType) {
|
||||||
|
let fileExtension = "";
|
||||||
|
if (file.name.lastIndexOf(".") > -1) {
|
||||||
|
fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
|
||||||
|
}
|
||||||
|
const isTypeOk = this.fileType.some((type) => {
|
||||||
|
if (file.type.indexOf(type) > -1) return true;
|
||||||
|
if (fileExtension && fileExtension.indexOf(type) > -1) return true;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
if (!isTypeOk) {
|
||||||
|
this.$message.error(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 校检文件大小
|
||||||
|
if (this.fileSize) {
|
||||||
|
const isLt = file.size / 1024 / 1024 < this.fileSize;
|
||||||
|
if (!isLt) {
|
||||||
|
this.$message.error(`上传文件大小不能超过 ${this.fileSize} MB!`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
// 文件个数超出
|
||||||
|
handleExceed() {
|
||||||
|
this.$message.error(`只允许上传单个文件`);
|
||||||
|
},
|
||||||
|
// 上传失败
|
||||||
|
handleUploadError(err) {
|
||||||
|
this.$message.error("上传失败, 请重试");
|
||||||
|
},
|
||||||
|
// 上传成功回调
|
||||||
|
handleUploadSuccess(res, file) {
|
||||||
|
this.$message.success("上传成功");
|
||||||
|
this.$emit("input", res.url);
|
||||||
|
},
|
||||||
|
// 删除文件
|
||||||
|
handleDelete(index) {
|
||||||
|
this.fileList.splice(index, 1);
|
||||||
|
this.$emit("input", '');
|
||||||
|
},
|
||||||
|
// 获取文件名称
|
||||||
|
getFileName(name) {
|
||||||
|
if (name.lastIndexOf("/") > -1) {
|
||||||
|
return name.slice(name.lastIndexOf("/") + 1).toLowerCase();
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.fileList = this.list;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.upload-file-uploader {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
.upload-file-list .el-upload-list__item {
|
||||||
|
border: 1px solid #e4e7ed;
|
||||||
|
line-height: 2;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.upload-file-list .ele-upload-list__item-content {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
.ele-upload-list__item-content-action .el-link {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,100 @@
|
||||||
|
<template>
|
||||||
|
<div class="component-upload-image">
|
||||||
|
<el-upload
|
||||||
|
:action="uploadImgUrl"
|
||||||
|
list-type="picture-card"
|
||||||
|
:on-success="handleUploadSuccess"
|
||||||
|
:before-upload="handleBeforeUpload"
|
||||||
|
:on-error="handleUploadError"
|
||||||
|
name="file"
|
||||||
|
:show-file-list="false"
|
||||||
|
:headers="headers"
|
||||||
|
style="display: inline-block; vertical-align: top"
|
||||||
|
>
|
||||||
|
<el-image v-if="!value" :src="value">
|
||||||
|
<div slot="error" class="image-slot">
|
||||||
|
<i class="el-icon-plus" />
|
||||||
|
</div>
|
||||||
|
</el-image>
|
||||||
|
<div v-else class="image">
|
||||||
|
<el-image :src="value" :style="`width:150px;height:150px;`" fit="fill"/>
|
||||||
|
<div class="mask">
|
||||||
|
<div class="actions">
|
||||||
|
<span title="预览" @click.stop="dialogVisible = true">
|
||||||
|
<i class="el-icon-zoom-in" />
|
||||||
|
</span>
|
||||||
|
<span title="移除" @click.stop="removeImage">
|
||||||
|
<i class="el-icon-delete" />
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-upload>
|
||||||
|
<el-dialog :visible.sync="dialogVisible" title="预览" width="800" append-to-body>
|
||||||
|
<img :src="value" style="display: block; max-width: 100%; margin: 0 auto;">
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getToken } from "@/utils/auth";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dialogVisible: false,
|
||||||
|
uploadImgUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址
|
||||||
|
headers: {
|
||||||
|
Authorization: "Bearer " + getToken(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
value: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
removeImage() {
|
||||||
|
this.$emit("input", "");
|
||||||
|
},
|
||||||
|
handleUploadSuccess(res) {
|
||||||
|
this.$emit("input", res.url);
|
||||||
|
this.loading.close();
|
||||||
|
},
|
||||||
|
handleBeforeUpload() {
|
||||||
|
this.loading = this.$loading({
|
||||||
|
lock: true,
|
||||||
|
text: "上传中",
|
||||||
|
background: "rgba(0, 0, 0, 0.7)",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleUploadError() {
|
||||||
|
this.$message({
|
||||||
|
type: "error",
|
||||||
|
message: "上传失败",
|
||||||
|
});
|
||||||
|
this.loading.close();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
watch: {},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.image {
|
||||||
|
position: relative;
|
||||||
|
.mask {
|
||||||
|
opacity: 0;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
width: 100%;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
|
transition: all 0.3s;
|
||||||
|
}
|
||||||
|
&:hover .mask {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,287 @@
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="java成绩" prop="java">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.java"
|
||||||
|
placeholder="请输入java成绩"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</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="['test:results: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="['test:results: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="['test:results: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="['test:results:export']"
|
||||||
|
>导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="resultsList" @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="学生id" align="center" prop="sId" />
|
||||||
|
<el-table-column label="java成绩" align="center" prop="java" />
|
||||||
|
<el-table-column label="图片路径" align="center" prop="images" />
|
||||||
|
<el-table-column label="文件路径" align="center" prop="file" />
|
||||||
|
<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="['test:results:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['test:results: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="学生id" prop="sId">
|
||||||
|
<el-input v-model="form.sId" placeholder="请输入学生id" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="java成绩" prop="java">
|
||||||
|
<el-input v-model="form.java" placeholder="请输入java成绩" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="图片路径">
|
||||||
|
<imageUpload v-model="form.images"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="文件路径">
|
||||||
|
<fileUpload v-model="form.file"/>
|
||||||
|
</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 { listResults, getResults, delResults, addResults, updateResults, exportResults } from "@/api/test/results";
|
||||||
|
import ImageUpload from '@/components/ImageUpload';
|
||||||
|
import FileUpload from '@/components/FileUpload';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "Results",
|
||||||
|
components: {
|
||||||
|
ImageUpload,
|
||||||
|
FileUpload,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 成绩表格数据
|
||||||
|
resultsList: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
java: null,
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
java: [
|
||||||
|
{ required: true, message: "java成绩不能为空}", trigger: "blur" },
|
||||||
|
],
|
||||||
|
images: [
|
||||||
|
{ required: true, message: "图片路径不能为空}", trigger: "blur" },
|
||||||
|
],
|
||||||
|
file: [
|
||||||
|
{ required: true, message: "文件路径不能为空}", trigger: "blur" },
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询成绩列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
listResults(this.queryParams).then(response => {
|
||||||
|
this.resultsList = response.rows;
|
||||||
|
this.total = response.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
id: null,
|
||||||
|
sId: null,
|
||||||
|
java: null,
|
||||||
|
images: null,
|
||||||
|
file: null
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
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
|
||||||
|
getResults(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) {
|
||||||
|
updateResults(this.form).then(response => {
|
||||||
|
this.msgSuccess("修改成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addResults(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 delResults(ids);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.msgSuccess("删除成功");
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
const queryParams = this.queryParams;
|
||||||
|
this.$confirm('是否确认导出所有成绩数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return exportResults(queryParams);
|
||||||
|
}).then(response => {
|
||||||
|
this.download(response.msg);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
@ -160,6 +160,16 @@
|
||||||
<el-input v-model="scope.row.java" placeholder="请输入java成绩" />
|
<el-input v-model="scope.row.java" placeholder="请输入java成绩" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column label="图片路径" prop="images">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<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="请输入文件路径" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</el-form>
|
</el-form>
|
||||||
<div slot="footer" class="dialog-footer">
|
<div slot="footer" class="dialog-footer">
|
||||||
|
|
@ -171,9 +181,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listStu, getStu, delStu, addStu, updateStu, exportStu } from "@/api/test/stu";
|
import { listStu, getStu, delStu, addStu, updateStu, exportStu } from "@/api/test/stu";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Stu",
|
name: "Stu",
|
||||||
components: {
|
components: {
|
||||||
},
|
},
|
||||||
|
|
@ -215,6 +225,17 @@
|
||||||
form: {},
|
form: {},
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
|
name: [
|
||||||
|
{ required: true, message: "学生姓名不能为空}", trigger: "blur" },
|
||||||
|
],
|
||||||
|
tel: [
|
||||||
|
{ 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"},
|
||||||
|
],
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
@ -243,8 +264,6 @@
|
||||||
name: null,
|
name: null,
|
||||||
tel: null,
|
tel: null,
|
||||||
email: null,
|
email: null,
|
||||||
createBy: null,
|
|
||||||
updateBy: null
|
|
||||||
};
|
};
|
||||||
this.resultsList = [];
|
this.resultsList = [];
|
||||||
this.resetForm("form");
|
this.resetForm("form");
|
||||||
|
|
@ -326,6 +345,8 @@
|
||||||
handleAddResults() {
|
handleAddResults() {
|
||||||
let obj = {};
|
let obj = {};
|
||||||
obj.java = "";
|
obj.java = "";
|
||||||
|
obj.images = "";
|
||||||
|
obj.file = "";
|
||||||
this.resultsList.push(obj);
|
this.resultsList.push(obj);
|
||||||
},
|
},
|
||||||
/** 成绩删除按钮操作 */
|
/** 成绩删除按钮操作 */
|
||||||
|
|
@ -359,5 +380,5 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,17 @@ package com.hchyun;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动程序
|
* 启动程序
|
||||||
*
|
*
|
||||||
* @author hchyun
|
* @author hchyun
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||||
public class HchYunApplication
|
//@EnableSwagger2
|
||||||
{
|
public class HchYunApplication {
|
||||||
public static void main(String[] args)
|
public static void main(String[] args) {
|
||||||
{
|
|
||||||
// System.setProperty("spring.devtools.restart.enabled", "false");
|
// System.setProperty("spring.devtools.restart.enabled", "false");
|
||||||
SpringApplication.run(HchYunApplication.class, args);
|
SpringApplication.run(HchYunApplication.class, args);
|
||||||
System.out.println("(♥◠‿◠)ノ゙ 宏驰云启动成功 ლ(´ڡ`ლ)゙ \n");
|
System.out.println("(♥◠‿◠)ノ゙ 宏驰云启动成功 ლ(´ڡ`ლ)゙ \n");
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.util.FastByteArrayOutputStream;
|
import org.springframework.util.FastByteArrayOutputStream;
|
||||||
|
|
@ -24,8 +25,7 @@ import com.hchyun.common.utils.uuid.IdUtils;
|
||||||
* @author hchyun
|
* @author hchyun
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
public class CaptchaController
|
public class CaptchaController {
|
||||||
{
|
|
||||||
@Resource(name = "captchaProducer")
|
@Resource(name = "captchaProducer")
|
||||||
private Producer captchaProducer;
|
private Producer captchaProducer;
|
||||||
|
|
||||||
|
|
@ -43,8 +43,7 @@ public class CaptchaController
|
||||||
* 生成验证码
|
* 生成验证码
|
||||||
*/
|
*/
|
||||||
@GetMapping("/captchaImage")
|
@GetMapping("/captchaImage")
|
||||||
public AjaxResult getCode(HttpServletResponse response) throws IOException
|
public AjaxResult getCode(HttpServletResponse response) throws IOException {
|
||||||
{
|
|
||||||
// 保存验证码信息
|
// 保存验证码信息
|
||||||
String uuid = IdUtils.simpleUUID();
|
String uuid = IdUtils.simpleUUID();
|
||||||
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
||||||
|
|
@ -53,15 +52,12 @@ public class CaptchaController
|
||||||
BufferedImage image = null;
|
BufferedImage image = null;
|
||||||
|
|
||||||
// 生成验证码
|
// 生成验证码
|
||||||
if ("math".equals(captchaType))
|
if ("math".equals(captchaType)) {
|
||||||
{
|
|
||||||
String capText = captchaProducerMath.createText();
|
String capText = captchaProducerMath.createText();
|
||||||
capStr = capText.substring(0, capText.lastIndexOf("@"));
|
capStr = capText.substring(0, capText.lastIndexOf("@"));
|
||||||
code = capText.substring(capText.lastIndexOf("@") + 1);
|
code = capText.substring(capText.lastIndexOf("@") + 1);
|
||||||
image = captchaProducerMath.createImage(capStr);
|
image = captchaProducerMath.createImage(capStr);
|
||||||
}
|
} else if ("char".equals(captchaType)) {
|
||||||
else if ("char".equals(captchaType))
|
|
||||||
{
|
|
||||||
capStr = code = captchaProducer.createText();
|
capStr = code = captchaProducer.createText();
|
||||||
image = captchaProducer.createImage(capStr);
|
image = captchaProducer.createImage(capStr);
|
||||||
}
|
}
|
||||||
|
|
@ -69,18 +65,15 @@ public class CaptchaController
|
||||||
redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
|
redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
|
||||||
// 转换流信息写出
|
// 转换流信息写出
|
||||||
FastByteArrayOutputStream os = new FastByteArrayOutputStream();
|
FastByteArrayOutputStream os = new FastByteArrayOutputStream();
|
||||||
try
|
try {
|
||||||
{
|
ImageIO.write(image, "jpg" , os);
|
||||||
ImageIO.write(image, "jpg", os);
|
} catch (IOException e) {
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
return AjaxResult.error(e.getMessage());
|
return AjaxResult.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
ajax.put("uuid", uuid);
|
ajax.put("uuid" , uuid);
|
||||||
ajax.put("img", Base64.encode(os.toByteArray()));
|
ajax.put("img" , Base64.encode(os.toByteArray()));
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.hchyun.web.controller.common;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -23,8 +24,7 @@ import com.hchyun.framework.config.ServerConfig;
|
||||||
* @author hchyun
|
* @author hchyun
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
public class CommonController
|
public class CommonController {
|
||||||
{
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
@ -37,30 +37,24 @@ public class CommonController
|
||||||
* @param delete 是否删除
|
* @param delete 是否删除
|
||||||
*/
|
*/
|
||||||
@GetMapping("common/download")
|
@GetMapping("common/download")
|
||||||
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
|
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) {
|
||||||
{
|
try {
|
||||||
try
|
if (!FileUtils.isValidFilename(fileName)) {
|
||||||
{
|
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 " , fileName));
|
||||||
if (!FileUtils.isValidFilename(fileName))
|
|
||||||
{
|
|
||||||
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
|
|
||||||
}
|
}
|
||||||
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
|
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
|
||||||
String filePath = HchYunConfig.getDownloadPath() + fileName;
|
String filePath = HchYunConfig.getDownloadPath() + fileName;
|
||||||
|
|
||||||
response.setCharacterEncoding("utf-8");
|
response.setCharacterEncoding("utf-8");
|
||||||
response.setContentType("multipart/form-data");
|
response.setContentType("multipart/form-data");
|
||||||
response.setHeader("Content-Disposition",
|
response.setHeader("Content-Disposition" ,
|
||||||
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName));
|
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName));
|
||||||
FileUtils.writeBytes(filePath, response.getOutputStream());
|
FileUtils.writeBytes(filePath, response.getOutputStream());
|
||||||
if (delete)
|
if (delete) {
|
||||||
{
|
|
||||||
FileUtils.deleteFile(filePath);
|
FileUtils.deleteFile(filePath);
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
log.error("下载文件失败" , e);
|
||||||
{
|
|
||||||
log.error("下载文件失败", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,22 +62,18 @@ public class CommonController
|
||||||
* 通用上传请求
|
* 通用上传请求
|
||||||
*/
|
*/
|
||||||
@PostMapping("/common/upload")
|
@PostMapping("/common/upload")
|
||||||
public AjaxResult uploadFile(MultipartFile file) throws Exception
|
public AjaxResult uploadFile(MultipartFile file) throws Exception {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
// 上传文件路径
|
// 上传文件路径
|
||||||
String filePath = HchYunConfig.getUploadPath();
|
String filePath = HchYunConfig.getUploadPath();
|
||||||
// 上传并返回新文件名称
|
// 上传并返回新文件名称
|
||||||
String fileName = FileUploadUtils.upload(filePath, file);
|
String fileName = FileUploadUtils.upload(filePath, file);
|
||||||
String url = serverConfig.getUrl() + fileName;
|
String url = serverConfig.getUrl() + fileName;
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
ajax.put("fileName", fileName);
|
ajax.put("fileName" , fileName);
|
||||||
ajax.put("url", url);
|
ajax.put("url" , url);
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return AjaxResult.error(e.getMessage());
|
return AjaxResult.error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -92,8 +82,7 @@ public class CommonController
|
||||||
* 本地资源通用下载
|
* 本地资源通用下载
|
||||||
*/
|
*/
|
||||||
@GetMapping("/common/download/resource")
|
@GetMapping("/common/download/resource")
|
||||||
public void resourceDownload(String name, HttpServletRequest request, HttpServletResponse response) throws Exception
|
public void resourceDownload(String name, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
{
|
|
||||||
// 本地资源路径
|
// 本地资源路径
|
||||||
String localPath = HchYunConfig.getProfile();
|
String localPath = HchYunConfig.getProfile();
|
||||||
// 数据库资源地址
|
// 数据库资源地址
|
||||||
|
|
@ -102,7 +91,7 @@ public class CommonController
|
||||||
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
|
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
|
||||||
response.setCharacterEncoding("utf-8");
|
response.setCharacterEncoding("utf-8");
|
||||||
response.setContentType("multipart/form-data");
|
response.setContentType("multipart/form-data");
|
||||||
response.setHeader("Content-Disposition",
|
response.setHeader("Content-Disposition" ,
|
||||||
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, downloadName));
|
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, downloadName));
|
||||||
FileUtils.writeBytes(downloadPath, response.getOutputStream());
|
FileUtils.writeBytes(downloadPath, response.getOutputStream());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,10 @@ import com.hchyun.framework.web.domain.Server;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/server")
|
@RequestMapping("/monitor/server")
|
||||||
public class ServerController extends BaseController
|
public class ServerController extends BaseController {
|
||||||
{
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
|
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public AjaxResult getInfo() throws Exception
|
public AjaxResult getInfo() throws Exception {
|
||||||
{
|
|
||||||
Server server = new Server();
|
Server server = new Server();
|
||||||
server.copyTo();
|
server.copyTo();
|
||||||
return AjaxResult.success(server);
|
return AjaxResult.success(server);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.hchyun.web.controller.monitor;
|
package com.hchyun.web.controller.monitor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
|
@ -24,43 +25,38 @@ import com.hchyun.system.service.ISysLogininforService;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/logininfor")
|
@RequestMapping("/monitor/logininfor")
|
||||||
public class SysLogininforController extends BaseController
|
public class SysLogininforController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysLogininforService logininforService;
|
private ISysLogininforService logininforService;
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(SysLogininfor logininfor)
|
public TableDataInfo list(SysLogininfor logininfor) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
@Log(title = "登录日志" , businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public AjaxResult export(SysLogininfor logininfor)
|
public AjaxResult export(SysLogininfor logininfor) {
|
||||||
{
|
|
||||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||||
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
||||||
return util.exportExcel(list, "登录日志");
|
return util.exportExcel(list, "登录日志");
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||||
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
@Log(title = "登录日志" , businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{infoIds}")
|
@DeleteMapping("/{infoIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] infoIds)
|
public AjaxResult remove(@PathVariable Long[] infoIds) {
|
||||||
{
|
|
||||||
return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||||
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
|
@Log(title = "登录日志" , businessType = BusinessType.CLEAN)
|
||||||
@DeleteMapping("/clean")
|
@DeleteMapping("/clean")
|
||||||
public AjaxResult clean()
|
public AjaxResult clean() {
|
||||||
{
|
|
||||||
logininforService.cleanLogininfor();
|
logininforService.cleanLogininfor();
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.hchyun.web.controller.monitor;
|
package com.hchyun.web.controller.monitor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
|
@ -24,25 +25,22 @@ import com.hchyun.system.service.ISysOperLogService;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/operlog")
|
@RequestMapping("/monitor/operlog")
|
||||||
public class SysOperlogController extends BaseController
|
public class SysOperlogController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysOperLogService operLogService;
|
private ISysOperLogService operLogService;
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
|
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(SysOperLog operLog)
|
public TableDataInfo list(SysOperLog operLog) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
@Log(title = "操作日志" , businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
|
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public AjaxResult export(SysOperLog operLog)
|
public AjaxResult export(SysOperLog operLog) {
|
||||||
{
|
|
||||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||||
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
|
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
|
||||||
return util.exportExcel(list, "操作日志");
|
return util.exportExcel(list, "操作日志");
|
||||||
|
|
@ -50,16 +48,14 @@ public class SysOperlogController extends BaseController
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||||
@DeleteMapping("/{operIds}")
|
@DeleteMapping("/{operIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] operIds)
|
public AjaxResult remove(@PathVariable Long[] operIds) {
|
||||||
{
|
|
||||||
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
@Log(title = "操作日志" , businessType = BusinessType.CLEAN)
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||||
@DeleteMapping("/clean")
|
@DeleteMapping("/clean")
|
||||||
public AjaxResult clean()
|
public AjaxResult clean() {
|
||||||
{
|
|
||||||
operLogService.cleanOperLog();
|
operLogService.cleanOperLog();
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
|
@ -30,8 +31,7 @@ import com.hchyun.system.service.ISysUserOnlineService;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/online")
|
@RequestMapping("/monitor/online")
|
||||||
public class SysUserOnlineController extends BaseController
|
public class SysUserOnlineController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserOnlineService userOnlineService;
|
private ISysUserOnlineService userOnlineService;
|
||||||
|
|
||||||
|
|
@ -40,36 +40,24 @@ public class SysUserOnlineController extends BaseController
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:online:list')")
|
@PreAuthorize("@ss.hasPermi('monitor:online:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(String ipaddr, String userName)
|
public TableDataInfo list(String ipaddr, String userName) {
|
||||||
{
|
|
||||||
Collection<String> keys = redisCache.keys(Constants.LOGIN_TOKEN_KEY + "*");
|
Collection<String> keys = redisCache.keys(Constants.LOGIN_TOKEN_KEY + "*");
|
||||||
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
|
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
|
||||||
for (String key : keys)
|
for (String key : keys) {
|
||||||
{
|
|
||||||
LoginUser user = redisCache.getCacheObject(key);
|
LoginUser user = redisCache.getCacheObject(key);
|
||||||
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName))
|
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) {
|
||||||
{
|
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) {
|
||||||
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername()))
|
|
||||||
{
|
|
||||||
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
||||||
}
|
}
|
||||||
}
|
} else if (StringUtils.isNotEmpty(ipaddr)) {
|
||||||
else if (StringUtils.isNotEmpty(ipaddr))
|
if (StringUtils.equals(ipaddr, user.getIpaddr())) {
|
||||||
{
|
|
||||||
if (StringUtils.equals(ipaddr, user.getIpaddr()))
|
|
||||||
{
|
|
||||||
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
|
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
|
||||||
}
|
}
|
||||||
}
|
} else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) {
|
||||||
else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser()))
|
if (StringUtils.equals(userName, user.getUsername())) {
|
||||||
{
|
|
||||||
if (StringUtils.equals(userName, user.getUsername()))
|
|
||||||
{
|
|
||||||
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
|
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
userOnlineList.add(userOnlineService.loginUserToUserOnline(user));
|
userOnlineList.add(userOnlineService.loginUserToUserOnline(user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -82,10 +70,9 @@ public class SysUserOnlineController extends BaseController
|
||||||
* 强退用户
|
* 强退用户
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
|
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
|
||||||
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
@Log(title = "在线用户" , businessType = BusinessType.FORCE)
|
||||||
@DeleteMapping("/{tokenId}")
|
@DeleteMapping("/{tokenId}")
|
||||||
public AjaxResult forceLogout(@PathVariable String tokenId)
|
public AjaxResult forceLogout(@PathVariable String tokenId) {
|
||||||
{
|
|
||||||
redisCache.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId);
|
redisCache.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ public class RegularController extends HcyBaseController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:regular:export')")
|
@PreAuthorize("@ss.hasPermi('system:regular:export')")
|
||||||
@Log(title = "校验规则", businessType = BusinessType.EXPORT)
|
@Log(title = "校验规则" , businessType = BusinessType.EXPORT)
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public AjaxResult export(Regular regular) {
|
public AjaxResult export(Regular regular) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -116,7 +116,7 @@ public class RegularController extends HcyBaseController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:regular:add')")
|
@PreAuthorize("@ss.hasPermi('system:regular:add')")
|
||||||
@Log(title = "校验规则", businessType = BusinessType.INSERT)
|
@Log(title = "校验规则" , businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody Regular regular) {
|
public AjaxResult add(@RequestBody Regular regular) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -129,7 +129,7 @@ public class RegularController extends HcyBaseController {
|
||||||
if (regular.getEnable() == null || regular.getEnable() < 0) {
|
if (regular.getEnable() == null || regular.getEnable() < 0) {
|
||||||
return AjaxResult.error("是否启用不能为空!");
|
return AjaxResult.error("是否启用不能为空!");
|
||||||
}
|
}
|
||||||
if (!verifyRegular(regular)){
|
if (!verifyRegular(regular)) {
|
||||||
return AjaxResult.error("正则表达式校验不通过!");
|
return AjaxResult.error("正则表达式校验不通过!");
|
||||||
}
|
}
|
||||||
ServerResult<Integer> serverResult = regularService.insertRegular(regular);
|
ServerResult<Integer> serverResult = regularService.insertRegular(regular);
|
||||||
|
|
@ -151,7 +151,7 @@ public class RegularController extends HcyBaseController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:regular:edit')")
|
@PreAuthorize("@ss.hasPermi('system:regular:edit')")
|
||||||
@Log(title = "校验规则", businessType = BusinessType.UPDATE)
|
@Log(title = "校验规则" , businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@RequestBody Regular regular) {
|
public AjaxResult edit(@RequestBody Regular regular) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -164,7 +164,7 @@ public class RegularController extends HcyBaseController {
|
||||||
if (regular.getEnable() == null || regular.getEnable() < 0) {
|
if (regular.getEnable() == null || regular.getEnable() < 0) {
|
||||||
return AjaxResult.error("是否启用不能为空!");
|
return AjaxResult.error("是否启用不能为空!");
|
||||||
}
|
}
|
||||||
if (!verifyRegular(regular)){
|
if (!verifyRegular(regular)) {
|
||||||
return AjaxResult.error("正则表达式校验不通过!");
|
return AjaxResult.error("正则表达式校验不通过!");
|
||||||
}
|
}
|
||||||
ServerResult<Integer> serverResult = regularService.updateRegular(regular);
|
ServerResult<Integer> serverResult = regularService.updateRegular(regular);
|
||||||
|
|
@ -186,7 +186,7 @@ public class RegularController extends HcyBaseController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:regular:remove')")
|
@PreAuthorize("@ss.hasPermi('system:regular:remove')")
|
||||||
@Log(title = "校验规则", businessType = BusinessType.DELETE)
|
@Log(title = "校验规则" , businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -205,7 +205,7 @@ public class RegularController extends HcyBaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean verifyRegular(Regular regular){
|
public boolean verifyRegular(Regular regular) {
|
||||||
return Pattern.matches(regular.getRegular(),regular.getValidation());
|
return Pattern.matches(regular.getRegular(), regular.getValidation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.hchyun.web.controller.system;
|
package com.hchyun.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -31,8 +32,7 @@ import com.hchyun.system.service.ISysConfigService;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/config")
|
@RequestMapping("/system/config")
|
||||||
public class SysConfigController extends BaseController
|
public class SysConfigController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysConfigService configService;
|
private ISysConfigService configService;
|
||||||
|
|
||||||
|
|
@ -41,18 +41,16 @@ public class SysConfigController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:config:list')")
|
@PreAuthorize("@ss.hasPermi('system:config:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(SysConfig config)
|
public TableDataInfo list(SysConfig config) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<SysConfig> list = configService.selectConfigList(config);
|
List<SysConfig> list = configService.selectConfigList(config);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
@Log(title = "参数管理" , businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('system:config:export')")
|
@PreAuthorize("@ss.hasPermi('system:config:export')")
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public AjaxResult export(SysConfig config)
|
public AjaxResult export(SysConfig config) {
|
||||||
{
|
|
||||||
List<SysConfig> list = configService.selectConfigList(config);
|
List<SysConfig> list = configService.selectConfigList(config);
|
||||||
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
|
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
|
||||||
return util.exportExcel(list, "参数数据");
|
return util.exportExcel(list, "参数数据");
|
||||||
|
|
@ -63,8 +61,7 @@ public class SysConfigController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:config:query')")
|
@PreAuthorize("@ss.hasPermi('system:config:query')")
|
||||||
@GetMapping(value = "/{configId}")
|
@GetMapping(value = "/{configId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long configId)
|
public AjaxResult getInfo(@PathVariable Long configId) {
|
||||||
{
|
|
||||||
return AjaxResult.success(configService.selectConfigById(configId));
|
return AjaxResult.success(configService.selectConfigById(configId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,8 +69,7 @@ public class SysConfigController extends BaseController
|
||||||
* 根据参数键名查询参数值
|
* 根据参数键名查询参数值
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/configKey/{configKey}")
|
@GetMapping(value = "/configKey/{configKey}")
|
||||||
public AjaxResult getConfigKey(@PathVariable String configKey)
|
public AjaxResult getConfigKey(@PathVariable String configKey) {
|
||||||
{
|
|
||||||
return AjaxResult.success(configService.selectConfigByKey(configKey));
|
return AjaxResult.success(configService.selectConfigByKey(configKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,13 +77,11 @@ public class SysConfigController extends BaseController
|
||||||
* 新增参数配置
|
* 新增参数配置
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:config:add')")
|
@PreAuthorize("@ss.hasPermi('system:config:add')")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
@Log(title = "参数管理" , businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@RepeatSubmit
|
@RepeatSubmit
|
||||||
public AjaxResult add(@Validated @RequestBody SysConfig config)
|
public AjaxResult add(@Validated @RequestBody SysConfig config) {
|
||||||
{
|
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
}
|
}
|
||||||
config.setCreateBy(SecurityUtils.getUserId());
|
config.setCreateBy(SecurityUtils.getUserId());
|
||||||
|
|
@ -98,12 +92,10 @@ public class SysConfigController extends BaseController
|
||||||
* 修改参数配置
|
* 修改参数配置
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:config:edit')")
|
@PreAuthorize("@ss.hasPermi('system:config:edit')")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
@Log(title = "参数管理" , businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysConfig config)
|
public AjaxResult edit(@Validated @RequestBody SysConfig config) {
|
||||||
{
|
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
}
|
}
|
||||||
config.setUpdateBy(SecurityUtils.getUserId());
|
config.setUpdateBy(SecurityUtils.getUserId());
|
||||||
|
|
@ -114,10 +106,9 @@ public class SysConfigController extends BaseController
|
||||||
* 删除参数配置
|
* 删除参数配置
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
@Log(title = "参数管理" , businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{configIds}")
|
@DeleteMapping("/{configIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] configIds)
|
public AjaxResult remove(@PathVariable Long[] configIds) {
|
||||||
{
|
|
||||||
return toAjax(configService.deleteConfigByIds(configIds));
|
return toAjax(configService.deleteConfigByIds(configIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -125,10 +116,9 @@ public class SysConfigController extends BaseController
|
||||||
* 清空缓存
|
* 清空缓存
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
@Log(title = "参数管理" , businessType = BusinessType.CLEAN)
|
||||||
@DeleteMapping("/clearCache")
|
@DeleteMapping("/clearCache")
|
||||||
public AjaxResult clearCache()
|
public AjaxResult clearCache() {
|
||||||
{
|
|
||||||
configService.clearCache();
|
configService.clearCache();
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.hchyun.web.controller.system;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
|
@ -31,8 +32,7 @@ import com.hchyun.system.service.ISysDeptService;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/dept")
|
@RequestMapping("/system/dept")
|
||||||
public class SysDeptController extends BaseController
|
public class SysDeptController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysDeptService deptService;
|
private ISysDeptService deptService;
|
||||||
|
|
||||||
|
|
@ -41,8 +41,7 @@ public class SysDeptController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult list(SysDept dept)
|
public AjaxResult list(SysDept dept) {
|
||||||
{
|
|
||||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||||
return AjaxResult.success(depts);
|
return AjaxResult.success(depts);
|
||||||
}
|
}
|
||||||
|
|
@ -52,16 +51,13 @@ public class SysDeptController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
||||||
@GetMapping("/list/exclude/{deptId}")
|
@GetMapping("/list/exclude/{deptId}")
|
||||||
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
|
public AjaxResult excludeChild(@PathVariable(value = "deptId" , required = false) Long deptId) {
|
||||||
{
|
|
||||||
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||||
Iterator<SysDept> it = depts.iterator();
|
Iterator<SysDept> it = depts.iterator();
|
||||||
while (it.hasNext())
|
while (it.hasNext()) {
|
||||||
{
|
|
||||||
SysDept d = (SysDept) it.next();
|
SysDept d = (SysDept) it.next();
|
||||||
if (d.getDeptId().intValue() == deptId
|
if (d.getDeptId().intValue() == deptId
|
||||||
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""))
|
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")) {
|
||||||
{
|
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -73,8 +69,7 @@ public class SysDeptController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dept:query')")
|
@PreAuthorize("@ss.hasPermi('system:dept:query')")
|
||||||
@GetMapping(value = "/{deptId}")
|
@GetMapping(value = "/{deptId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long deptId)
|
public AjaxResult getInfo(@PathVariable Long deptId) {
|
||||||
{
|
|
||||||
return AjaxResult.success(deptService.selectDeptById(deptId));
|
return AjaxResult.success(deptService.selectDeptById(deptId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,8 +77,7 @@ public class SysDeptController extends BaseController
|
||||||
* 获取部门下拉树列表
|
* 获取部门下拉树列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/treeselect")
|
@GetMapping("/treeselect")
|
||||||
public AjaxResult treeselect(SysDept dept)
|
public AjaxResult treeselect(SysDept dept) {
|
||||||
{
|
|
||||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||||
return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
|
return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
|
||||||
}
|
}
|
||||||
|
|
@ -92,12 +86,11 @@ public class SysDeptController extends BaseController
|
||||||
* 加载对应角色部门列表树
|
* 加载对应角色部门列表树
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
|
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
|
||||||
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId)
|
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId) {
|
||||||
{
|
|
||||||
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
ajax.put("checkedKeys" , deptService.selectDeptListByRoleId(roleId));
|
||||||
ajax.put("depts", deptService.buildDeptTreeSelect(depts));
|
ajax.put("depts" , deptService.buildDeptTreeSelect(depts));
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,12 +98,10 @@ public class SysDeptController extends BaseController
|
||||||
* 新增部门
|
* 新增部门
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dept:add')")
|
@PreAuthorize("@ss.hasPermi('system:dept:add')")
|
||||||
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
@Log(title = "部门管理" , businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysDept dept)
|
public AjaxResult add(@Validated @RequestBody SysDept dept) {
|
||||||
{
|
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
}
|
}
|
||||||
dept.setCreateBy(SecurityUtils.getUserId());
|
dept.setCreateBy(SecurityUtils.getUserId());
|
||||||
|
|
@ -121,21 +112,15 @@ public class SysDeptController extends BaseController
|
||||||
* 修改部门
|
* 修改部门
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dept:edit')")
|
@PreAuthorize("@ss.hasPermi('system:dept:edit')")
|
||||||
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
@Log(title = "部门管理" , businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysDept dept)
|
public AjaxResult edit(@Validated @RequestBody SysDept dept) {
|
||||||
{
|
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
}
|
} else if (dept.getParentId().equals(dept.getDeptId())) {
|
||||||
else if (dept.getParentId().equals(dept.getDeptId()))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||||
}
|
} else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
||||||
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
&& deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) {
|
||||||
&& deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0)
|
|
||||||
{
|
|
||||||
return AjaxResult.error("该部门包含未停用的子部门!");
|
return AjaxResult.error("该部门包含未停用的子部门!");
|
||||||
}
|
}
|
||||||
dept.setUpdateBy(SecurityUtils.getUserId());
|
dept.setUpdateBy(SecurityUtils.getUserId());
|
||||||
|
|
@ -146,16 +131,13 @@ public class SysDeptController extends BaseController
|
||||||
* 删除部门
|
* 删除部门
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dept:remove')")
|
@PreAuthorize("@ss.hasPermi('system:dept:remove')")
|
||||||
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
@Log(title = "部门管理" , businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{deptId}")
|
@DeleteMapping("/{deptId}")
|
||||||
public AjaxResult remove(@PathVariable Long deptId)
|
public AjaxResult remove(@PathVariable Long deptId) {
|
||||||
{
|
if (deptService.hasChildByDeptId(deptId)) {
|
||||||
if (deptService.hasChildByDeptId(deptId))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("存在下级部门,不允许删除");
|
return AjaxResult.error("存在下级部门,不允许删除");
|
||||||
}
|
}
|
||||||
if (deptService.checkDeptExistUser(deptId))
|
if (deptService.checkDeptExistUser(deptId)) {
|
||||||
{
|
|
||||||
return AjaxResult.error("部门存在用户,不允许删除");
|
return AjaxResult.error("部门存在用户,不允许删除");
|
||||||
}
|
}
|
||||||
return toAjax(deptService.deleteDeptById(deptId));
|
return toAjax(deptService.deleteDeptById(deptId));
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.hchyun.web.controller.system;
|
package com.hchyun.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -30,8 +31,7 @@ import com.hchyun.system.service.ISysDictTypeService;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/dict/data")
|
@RequestMapping("/system/dict/data")
|
||||||
public class SysDictDataController extends BaseController
|
public class SysDictDataController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysDictDataService dictDataService;
|
private ISysDictDataService dictDataService;
|
||||||
|
|
||||||
|
|
@ -40,18 +40,16 @@ public class SysDictDataController extends BaseController
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(SysDictData dictData)
|
public TableDataInfo list(SysDictData dictData) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
@Log(title = "字典数据" , businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public AjaxResult export(SysDictData dictData)
|
public AjaxResult export(SysDictData dictData) {
|
||||||
{
|
|
||||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||||
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
|
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
|
||||||
return util.exportExcel(list, "字典数据");
|
return util.exportExcel(list, "字典数据");
|
||||||
|
|
@ -62,8 +60,7 @@ public class SysDictDataController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||||
@GetMapping(value = "/{dictCode}")
|
@GetMapping(value = "/{dictCode}")
|
||||||
public AjaxResult getInfo(@PathVariable Long dictCode)
|
public AjaxResult getInfo(@PathVariable Long dictCode) {
|
||||||
{
|
|
||||||
return AjaxResult.success(dictDataService.selectDictDataById(dictCode));
|
return AjaxResult.success(dictDataService.selectDictDataById(dictCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,8 +68,7 @@ public class SysDictDataController extends BaseController
|
||||||
* 根据字典类型查询字典数据信息
|
* 根据字典类型查询字典数据信息
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/type/{dictType}")
|
@GetMapping(value = "/type/{dictType}")
|
||||||
public AjaxResult dictType(@PathVariable String dictType)
|
public AjaxResult dictType(@PathVariable String dictType) {
|
||||||
{
|
|
||||||
return AjaxResult.success(dictTypeService.selectDictDataByType(dictType));
|
return AjaxResult.success(dictTypeService.selectDictDataByType(dictType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,10 +76,9 @@ public class SysDictDataController extends BaseController
|
||||||
* 新增字典类型
|
* 新增字典类型
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||||
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
@Log(title = "字典数据" , businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysDictData dict)
|
public AjaxResult add(@Validated @RequestBody SysDictData dict) {
|
||||||
{
|
|
||||||
dict.setCreateBy(SecurityUtils.getUserId());
|
dict.setCreateBy(SecurityUtils.getUserId());
|
||||||
return toAjax(dictDataService.insertDictData(dict));
|
return toAjax(dictDataService.insertDictData(dict));
|
||||||
}
|
}
|
||||||
|
|
@ -92,10 +87,9 @@ public class SysDictDataController extends BaseController
|
||||||
* 修改保存字典类型
|
* 修改保存字典类型
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||||
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
@Log(title = "字典数据" , businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysDictData dict)
|
public AjaxResult edit(@Validated @RequestBody SysDictData dict) {
|
||||||
{
|
|
||||||
dict.setUpdateBy(SecurityUtils.getUserId());
|
dict.setUpdateBy(SecurityUtils.getUserId());
|
||||||
return toAjax(dictDataService.updateDictData(dict));
|
return toAjax(dictDataService.updateDictData(dict));
|
||||||
}
|
}
|
||||||
|
|
@ -104,10 +98,9 @@ public class SysDictDataController extends BaseController
|
||||||
* 删除字典类型
|
* 删除字典类型
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
@Log(title = "字典类型" , businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{dictCodes}")
|
@DeleteMapping("/{dictCodes}")
|
||||||
public AjaxResult remove(@PathVariable Long[] dictCodes)
|
public AjaxResult remove(@PathVariable Long[] dictCodes) {
|
||||||
{
|
|
||||||
return toAjax(dictDataService.deleteDictDataByIds(dictCodes));
|
return toAjax(dictDataService.deleteDictDataByIds(dictCodes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.hchyun.web.controller.system;
|
package com.hchyun.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -30,25 +31,22 @@ import com.hchyun.system.service.ISysDictTypeService;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/dict/type")
|
@RequestMapping("/system/dict/type")
|
||||||
public class SysDictTypeController extends BaseController
|
public class SysDictTypeController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysDictTypeService dictTypeService;
|
private ISysDictTypeService dictTypeService;
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(SysDictType dictType)
|
public TableDataInfo list(SysDictType dictType) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
@Log(title = "字典类型" , businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public AjaxResult export(SysDictType dictType)
|
public AjaxResult export(SysDictType dictType) {
|
||||||
{
|
|
||||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||||
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
|
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
|
||||||
return util.exportExcel(list, "字典类型");
|
return util.exportExcel(list, "字典类型");
|
||||||
|
|
@ -59,8 +57,7 @@ public class SysDictTypeController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||||
@GetMapping(value = "/{dictId}")
|
@GetMapping(value = "/{dictId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long dictId)
|
public AjaxResult getInfo(@PathVariable Long dictId) {
|
||||||
{
|
|
||||||
return AjaxResult.success(dictTypeService.selectDictTypeById(dictId));
|
return AjaxResult.success(dictTypeService.selectDictTypeById(dictId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,12 +65,10 @@ public class SysDictTypeController extends BaseController
|
||||||
* 新增字典类型
|
* 新增字典类型
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
@Log(title = "字典类型" , businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysDictType dict)
|
public AjaxResult add(@Validated @RequestBody SysDictType dict) {
|
||||||
{
|
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||||
}
|
}
|
||||||
dict.setCreateBy(SecurityUtils.getUserId());
|
dict.setCreateBy(SecurityUtils.getUserId());
|
||||||
|
|
@ -84,12 +79,10 @@ public class SysDictTypeController extends BaseController
|
||||||
* 修改字典类型
|
* 修改字典类型
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
@Log(title = "字典类型" , businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysDictType dict)
|
public AjaxResult edit(@Validated @RequestBody SysDictType dict) {
|
||||||
{
|
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||||
}
|
}
|
||||||
dict.setUpdateBy(SecurityUtils.getUserId());
|
dict.setUpdateBy(SecurityUtils.getUserId());
|
||||||
|
|
@ -100,10 +93,9 @@ public class SysDictTypeController extends BaseController
|
||||||
* 删除字典类型
|
* 删除字典类型
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
@Log(title = "字典类型" , businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{dictIds}")
|
@DeleteMapping("/{dictIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] dictIds)
|
public AjaxResult remove(@PathVariable Long[] dictIds) {
|
||||||
{
|
|
||||||
return toAjax(dictTypeService.deleteDictTypeByIds(dictIds));
|
return toAjax(dictTypeService.deleteDictTypeByIds(dictIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,10 +103,9 @@ public class SysDictTypeController extends BaseController
|
||||||
* 清空缓存
|
* 清空缓存
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
@Log(title = "字典类型" , businessType = BusinessType.CLEAN)
|
||||||
@DeleteMapping("/clearCache")
|
@DeleteMapping("/clearCache")
|
||||||
public AjaxResult clearCache()
|
public AjaxResult clearCache() {
|
||||||
{
|
|
||||||
dictTypeService.clearCache();
|
dictTypeService.clearCache();
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
@ -123,8 +114,7 @@ public class SysDictTypeController extends BaseController
|
||||||
* 获取字典选择框列表
|
* 获取字典选择框列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/optionselect")
|
@GetMapping("/optionselect")
|
||||||
public AjaxResult optionselect()
|
public AjaxResult optionselect() {
|
||||||
{
|
|
||||||
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
||||||
return AjaxResult.success(dictTypes);
|
return AjaxResult.success(dictTypes);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.hchyun.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
@ -25,8 +26,7 @@ import com.hchyun.system.service.ISysMenuService;
|
||||||
* @author hchyun
|
* @author hchyun
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
public class SysLoginController
|
public class SysLoginController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysLoginService loginService;
|
private SysLoginService loginService;
|
||||||
|
|
||||||
|
|
@ -46,8 +46,7 @@ public class SysLoginController
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public AjaxResult login(@RequestBody LoginBody loginBody)
|
public AjaxResult login(@RequestBody LoginBody loginBody) {
|
||||||
{
|
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
// 生成令牌
|
// 生成令牌
|
||||||
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
||||||
|
|
@ -62,8 +61,7 @@ public class SysLoginController
|
||||||
* @return 用户信息
|
* @return 用户信息
|
||||||
*/
|
*/
|
||||||
@GetMapping("getInfo")
|
@GetMapping("getInfo")
|
||||||
public AjaxResult getInfo()
|
public AjaxResult getInfo() {
|
||||||
{
|
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
SysUser user = loginUser.getUser();
|
SysUser user = loginUser.getUser();
|
||||||
// 角色集合
|
// 角色集合
|
||||||
|
|
@ -71,9 +69,9 @@ public class SysLoginController
|
||||||
// 权限集合
|
// 权限集合
|
||||||
Set<String> permissions = permissionService.getMenuPermission(user);
|
Set<String> permissions = permissionService.getMenuPermission(user);
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
ajax.put("user", user);
|
ajax.put("user" , user);
|
||||||
ajax.put("roles", roles);
|
ajax.put("roles" , roles);
|
||||||
ajax.put("permissions", permissions);
|
ajax.put("permissions" , permissions);
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,8 +81,7 @@ public class SysLoginController
|
||||||
* @return 路由信息
|
* @return 路由信息
|
||||||
*/
|
*/
|
||||||
@GetMapping("getRouters")
|
@GetMapping("getRouters")
|
||||||
public AjaxResult getRouters()
|
public AjaxResult getRouters() {
|
||||||
{
|
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
// 用户信息
|
// 用户信息
|
||||||
SysUser user = loginUser.getUser();
|
SysUser user = loginUser.getUser();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.hchyun.web.controller.system;
|
package com.hchyun.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -33,8 +34,7 @@ import com.hchyun.system.service.ISysMenuService;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/menu")
|
@RequestMapping("/system/menu")
|
||||||
public class SysMenuController extends BaseController
|
public class SysMenuController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysMenuService menuService;
|
private ISysMenuService menuService;
|
||||||
|
|
||||||
|
|
@ -46,8 +46,7 @@ public class SysMenuController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:menu:list')")
|
@PreAuthorize("@ss.hasPermi('system:menu:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult list(SysMenu menu)
|
public AjaxResult list(SysMenu menu) {
|
||||||
{
|
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
Long userId = loginUser.getUser().getUserId();
|
Long userId = loginUser.getUser().getUserId();
|
||||||
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
||||||
|
|
@ -59,8 +58,7 @@ public class SysMenuController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:menu:query')")
|
@PreAuthorize("@ss.hasPermi('system:menu:query')")
|
||||||
@GetMapping(value = "/{menuId}")
|
@GetMapping(value = "/{menuId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long menuId)
|
public AjaxResult getInfo(@PathVariable Long menuId) {
|
||||||
{
|
|
||||||
return AjaxResult.success(menuService.selectMenuById(menuId));
|
return AjaxResult.success(menuService.selectMenuById(menuId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,8 +66,7 @@ public class SysMenuController extends BaseController
|
||||||
* 获取菜单下拉树列表
|
* 获取菜单下拉树列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/treeselect")
|
@GetMapping("/treeselect")
|
||||||
public AjaxResult treeselect(SysMenu menu)
|
public AjaxResult treeselect(SysMenu menu) {
|
||||||
{
|
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
Long userId = loginUser.getUser().getUserId();
|
Long userId = loginUser.getUser().getUserId();
|
||||||
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
||||||
|
|
@ -80,13 +77,12 @@ public class SysMenuController extends BaseController
|
||||||
* 加载对应角色菜单列表树
|
* 加载对应角色菜单列表树
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
||||||
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
|
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
|
||||||
{
|
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
List<SysMenu> menus = menuService.selectMenuList(loginUser.getUser().getUserId());
|
List<SysMenu> menus = menuService.selectMenuList(loginUser.getUser().getUserId());
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
ajax.put("checkedKeys" , menuService.selectMenuListByRoleId(roleId));
|
||||||
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
|
ajax.put("menus" , menuService.buildMenuTreeSelect(menus));
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,17 +90,13 @@ public class SysMenuController extends BaseController
|
||||||
* 新增菜单
|
* 新增菜单
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:menu:add')")
|
@PreAuthorize("@ss.hasPermi('system:menu:add')")
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
@Log(title = "菜单管理" , businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysMenu menu)
|
public AjaxResult add(@Validated @RequestBody SysMenu menu) {
|
||||||
{
|
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||||
}
|
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
|
||||||
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
|
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) {
|
||||||
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||||
}
|
}
|
||||||
menu.setCreateBy(SecurityUtils.getUserId());
|
menu.setCreateBy(SecurityUtils.getUserId());
|
||||||
|
|
@ -115,21 +107,15 @@ public class SysMenuController extends BaseController
|
||||||
* 修改菜单
|
* 修改菜单
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:menu:edit')")
|
@PreAuthorize("@ss.hasPermi('system:menu:edit')")
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
@Log(title = "菜单管理" , businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysMenu menu)
|
public AjaxResult edit(@Validated @RequestBody SysMenu menu) {
|
||||||
{
|
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||||
}
|
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
|
||||||
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
|
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) {
|
||||||
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||||
}
|
} else if (menu.getMenuId().equals(menu.getParentId())) {
|
||||||
else if (menu.getMenuId().equals(menu.getParentId()))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
||||||
}
|
}
|
||||||
menu.setUpdateBy(SecurityUtils.getUserId());
|
menu.setUpdateBy(SecurityUtils.getUserId());
|
||||||
|
|
@ -140,16 +126,13 @@ public class SysMenuController extends BaseController
|
||||||
* 删除菜单
|
* 删除菜单
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:menu:remove')")
|
@PreAuthorize("@ss.hasPermi('system:menu:remove')")
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
@Log(title = "菜单管理" , businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{menuId}")
|
@DeleteMapping("/{menuId}")
|
||||||
public AjaxResult remove(@PathVariable("menuId") Long menuId)
|
public AjaxResult remove(@PathVariable("menuId") Long menuId) {
|
||||||
{
|
if (menuService.hasChildByMenuId(menuId)) {
|
||||||
if (menuService.hasChildByMenuId(menuId))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("存在子菜单,不允许删除");
|
return AjaxResult.error("存在子菜单,不允许删除");
|
||||||
}
|
}
|
||||||
if (menuService.checkMenuExistRole(menuId))
|
if (menuService.checkMenuExistRole(menuId)) {
|
||||||
{
|
|
||||||
return AjaxResult.error("菜单已分配,不允许删除");
|
return AjaxResult.error("菜单已分配,不允许删除");
|
||||||
}
|
}
|
||||||
return toAjax(menuService.deleteMenuById(menuId));
|
return toAjax(menuService.deleteMenuById(menuId));
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.hchyun.web.controller.system;
|
package com.hchyun.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -28,8 +29,7 @@ import com.hchyun.system.service.ISysNoticeService;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/notice")
|
@RequestMapping("/system/notice")
|
||||||
public class SysNoticeController extends BaseController
|
public class SysNoticeController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysNoticeService noticeService;
|
private ISysNoticeService noticeService;
|
||||||
|
|
||||||
|
|
@ -38,8 +38,7 @@ public class SysNoticeController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:notice:list')")
|
@PreAuthorize("@ss.hasPermi('system:notice:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(SysNotice notice)
|
public TableDataInfo list(SysNotice notice) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<SysNotice> list = noticeService.selectNoticeList(notice);
|
List<SysNotice> list = noticeService.selectNoticeList(notice);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
|
|
@ -50,8 +49,7 @@ public class SysNoticeController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:notice:query')")
|
@PreAuthorize("@ss.hasPermi('system:notice:query')")
|
||||||
@GetMapping(value = "/{noticeId}")
|
@GetMapping(value = "/{noticeId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long noticeId)
|
public AjaxResult getInfo(@PathVariable Long noticeId) {
|
||||||
{
|
|
||||||
return AjaxResult.success(noticeService.selectNoticeById(noticeId));
|
return AjaxResult.success(noticeService.selectNoticeById(noticeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,10 +57,9 @@ public class SysNoticeController extends BaseController
|
||||||
* 新增通知公告
|
* 新增通知公告
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:notice:add')")
|
@PreAuthorize("@ss.hasPermi('system:notice:add')")
|
||||||
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
@Log(title = "通知公告" , businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysNotice notice)
|
public AjaxResult add(@Validated @RequestBody SysNotice notice) {
|
||||||
{
|
|
||||||
notice.setCreateBy(SecurityUtils.getUserId());
|
notice.setCreateBy(SecurityUtils.getUserId());
|
||||||
return toAjax(noticeService.insertNotice(notice));
|
return toAjax(noticeService.insertNotice(notice));
|
||||||
}
|
}
|
||||||
|
|
@ -71,10 +68,9 @@ public class SysNoticeController extends BaseController
|
||||||
* 修改通知公告
|
* 修改通知公告
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:notice:edit')")
|
@PreAuthorize("@ss.hasPermi('system:notice:edit')")
|
||||||
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
@Log(title = "通知公告" , businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysNotice notice)
|
public AjaxResult edit(@Validated @RequestBody SysNotice notice) {
|
||||||
{
|
|
||||||
notice.setUpdateBy(SecurityUtils.getUserId());
|
notice.setUpdateBy(SecurityUtils.getUserId());
|
||||||
return toAjax(noticeService.updateNotice(notice));
|
return toAjax(noticeService.updateNotice(notice));
|
||||||
}
|
}
|
||||||
|
|
@ -83,10 +79,9 @@ public class SysNoticeController extends BaseController
|
||||||
* 删除通知公告
|
* 删除通知公告
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:notice:remove')")
|
@PreAuthorize("@ss.hasPermi('system:notice:remove')")
|
||||||
@Log(title = "通知公告", businessType = BusinessType.DELETE)
|
@Log(title = "通知公告" , businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{noticeIds}")
|
@DeleteMapping("/{noticeIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] noticeIds)
|
public AjaxResult remove(@PathVariable Long[] noticeIds) {
|
||||||
{
|
|
||||||
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.hchyun.web.controller.system;
|
package com.hchyun.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -30,8 +31,7 @@ import com.hchyun.system.service.ISysPostService;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/post")
|
@RequestMapping("/system/post")
|
||||||
public class SysPostController extends BaseController
|
public class SysPostController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysPostService postService;
|
private ISysPostService postService;
|
||||||
|
|
||||||
|
|
@ -40,18 +40,16 @@ public class SysPostController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:list')")
|
@PreAuthorize("@ss.hasPermi('system:post:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(SysPost post)
|
public TableDataInfo list(SysPost post) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<SysPost> list = postService.selectPostList(post);
|
List<SysPost> list = postService.selectPostList(post);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
@Log(title = "岗位管理" , businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:export')")
|
@PreAuthorize("@ss.hasPermi('system:post:export')")
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public AjaxResult export(SysPost post)
|
public AjaxResult export(SysPost post) {
|
||||||
{
|
|
||||||
List<SysPost> list = postService.selectPostList(post);
|
List<SysPost> list = postService.selectPostList(post);
|
||||||
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
||||||
return util.exportExcel(list, "岗位数据");
|
return util.exportExcel(list, "岗位数据");
|
||||||
|
|
@ -62,8 +60,7 @@ public class SysPostController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:query')")
|
@PreAuthorize("@ss.hasPermi('system:post:query')")
|
||||||
@GetMapping(value = "/{postId}")
|
@GetMapping(value = "/{postId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long postId)
|
public AjaxResult getInfo(@PathVariable Long postId) {
|
||||||
{
|
|
||||||
return AjaxResult.success(postService.selectPostById(postId));
|
return AjaxResult.success(postService.selectPostById(postId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,16 +68,12 @@ public class SysPostController extends BaseController
|
||||||
* 新增岗位
|
* 新增岗位
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:add')")
|
@PreAuthorize("@ss.hasPermi('system:post:add')")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
@Log(title = "岗位管理" , businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysPost post)
|
public AjaxResult add(@Validated @RequestBody SysPost post) {
|
||||||
{
|
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||||
}
|
} else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) {
|
||||||
else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||||
}
|
}
|
||||||
post.setCreateBy(SecurityUtils.getUserId());
|
post.setCreateBy(SecurityUtils.getUserId());
|
||||||
|
|
@ -91,16 +84,12 @@ public class SysPostController extends BaseController
|
||||||
* 修改岗位
|
* 修改岗位
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:edit')")
|
@PreAuthorize("@ss.hasPermi('system:post:edit')")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
@Log(title = "岗位管理" , businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysPost post)
|
public AjaxResult edit(@Validated @RequestBody SysPost post) {
|
||||||
{
|
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||||
}
|
} else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) {
|
||||||
else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||||
}
|
}
|
||||||
post.setUpdateBy(SecurityUtils.getUserId());
|
post.setUpdateBy(SecurityUtils.getUserId());
|
||||||
|
|
@ -111,10 +100,9 @@ public class SysPostController extends BaseController
|
||||||
* 删除岗位
|
* 删除岗位
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:remove')")
|
@PreAuthorize("@ss.hasPermi('system:post:remove')")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
@Log(title = "岗位管理" , businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{postIds}")
|
@DeleteMapping("/{postIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] postIds)
|
public AjaxResult remove(@PathVariable Long[] postIds) {
|
||||||
{
|
|
||||||
return toAjax(postService.deletePostByIds(postIds));
|
return toAjax(postService.deletePostByIds(postIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,8 +110,7 @@ public class SysPostController extends BaseController
|
||||||
* 获取岗位选择框列表
|
* 获取岗位选择框列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/optionselect")
|
@GetMapping("/optionselect")
|
||||||
public AjaxResult optionselect()
|
public AjaxResult optionselect() {
|
||||||
{
|
|
||||||
List<SysPost> posts = postService.selectPostAll();
|
List<SysPost> posts = postService.selectPostAll();
|
||||||
return AjaxResult.success(posts);
|
return AjaxResult.success(posts);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.hchyun.web.controller.system;
|
package com.hchyun.web.controller.system;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
@ -30,8 +31,7 @@ import com.hchyun.system.service.ISysUserService;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/user/profile")
|
@RequestMapping("/system/user/profile")
|
||||||
public class SysProfileController extends BaseController
|
public class SysProfileController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserService userService;
|
private ISysUserService userService;
|
||||||
|
|
||||||
|
|
@ -42,25 +42,22 @@ public class SysProfileController extends BaseController
|
||||||
* 个人信息
|
* 个人信息
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public AjaxResult profile()
|
public AjaxResult profile() {
|
||||||
{
|
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
SysUser user = loginUser.getUser();
|
SysUser user = loginUser.getUser();
|
||||||
AjaxResult ajax = AjaxResult.success(user);
|
AjaxResult ajax = AjaxResult.success(user);
|
||||||
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
|
ajax.put("roleGroup" , userService.selectUserRoleGroup(loginUser.getUsername()));
|
||||||
ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername()));
|
ajax.put("postGroup" , userService.selectUserPostGroup(loginUser.getUsername()));
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户
|
* 修改用户
|
||||||
*/
|
*/
|
||||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
@Log(title = "个人信息" , businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult updateProfile(@RequestBody SysUser user)
|
public AjaxResult updateProfile(@RequestBody SysUser user) {
|
||||||
{
|
if (userService.updateUserProfile(user) > 0) {
|
||||||
if (userService.updateUserProfile(user) > 0)
|
|
||||||
{
|
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
// 更新缓存用户信息
|
// 更新缓存用户信息
|
||||||
loginUser.getUser().setNickName(user.getNickName());
|
loginUser.getUser().setNickName(user.getNickName());
|
||||||
|
|
@ -76,23 +73,19 @@ public class SysProfileController extends BaseController
|
||||||
/**
|
/**
|
||||||
* 重置密码
|
* 重置密码
|
||||||
*/
|
*/
|
||||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
@Log(title = "个人信息" , businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/updatePwd")
|
@PutMapping("/updatePwd")
|
||||||
public AjaxResult updatePwd(String oldPassword, String newPassword)
|
public AjaxResult updatePwd(String oldPassword, String newPassword) {
|
||||||
{
|
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
String userName = loginUser.getUsername();
|
String userName = loginUser.getUsername();
|
||||||
String password = loginUser.getPassword();
|
String password = loginUser.getPassword();
|
||||||
if (!SecurityUtils.matchesPassword(oldPassword, password))
|
if (!SecurityUtils.matchesPassword(oldPassword, password)) {
|
||||||
{
|
|
||||||
return AjaxResult.error("修改密码失败,旧密码错误");
|
return AjaxResult.error("修改密码失败,旧密码错误");
|
||||||
}
|
}
|
||||||
if (SecurityUtils.matchesPassword(newPassword, password))
|
if (SecurityUtils.matchesPassword(newPassword, password)) {
|
||||||
{
|
|
||||||
return AjaxResult.error("新密码不能与旧密码相同");
|
return AjaxResult.error("新密码不能与旧密码相同");
|
||||||
}
|
}
|
||||||
if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0)
|
if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0) {
|
||||||
{
|
|
||||||
// 更新缓存用户密码
|
// 更新缓存用户密码
|
||||||
loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
|
loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
|
||||||
tokenService.setLoginUser(loginUser);
|
tokenService.setLoginUser(loginUser);
|
||||||
|
|
@ -104,18 +97,15 @@ public class SysProfileController extends BaseController
|
||||||
/**
|
/**
|
||||||
* 头像上传
|
* 头像上传
|
||||||
*/
|
*/
|
||||||
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
@Log(title = "用户头像" , businessType = BusinessType.UPDATE)
|
||||||
@PostMapping("/avatar")
|
@PostMapping("/avatar")
|
||||||
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException
|
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException {
|
||||||
{
|
if (!file.isEmpty()) {
|
||||||
if (!file.isEmpty())
|
|
||||||
{
|
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
String avatar = FileUploadUtils.upload(HchYunConfig.getAvatarPath(), file);
|
String avatar = FileUploadUtils.upload(HchYunConfig.getAvatarPath(), file);
|
||||||
if (userService.updateUserAvatar(loginUser.getUsername(), avatar))
|
if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) {
|
||||||
{
|
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
ajax.put("imgUrl", avatar);
|
ajax.put("imgUrl" , avatar);
|
||||||
// 更新缓存用户头像
|
// 更新缓存用户头像
|
||||||
loginUser.getUser().setAvatar(avatar);
|
loginUser.getUser().setAvatar(avatar);
|
||||||
tokenService.setLoginUser(loginUser);
|
tokenService.setLoginUser(loginUser);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.hchyun.web.controller.system;
|
package com.hchyun.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -36,8 +37,7 @@ import com.hchyun.system.service.ISysUserService;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/role")
|
@RequestMapping("/system/role")
|
||||||
public class SysRoleController extends BaseController
|
public class SysRoleController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysRoleService roleService;
|
private ISysRoleService roleService;
|
||||||
|
|
||||||
|
|
@ -52,18 +52,16 @@ public class SysRoleController extends BaseController
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(SysRole role)
|
public TableDataInfo list(SysRole role) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<SysRole> list = roleService.selectRoleList(role);
|
List<SysRole> list = roleService.selectRoleList(role);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
@Log(title = "角色管理" , businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:export')")
|
@PreAuthorize("@ss.hasPermi('system:role:export')")
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public AjaxResult export(SysRole role)
|
public AjaxResult export(SysRole role) {
|
||||||
{
|
|
||||||
List<SysRole> list = roleService.selectRoleList(role);
|
List<SysRole> list = roleService.selectRoleList(role);
|
||||||
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
||||||
return util.exportExcel(list, "角色数据");
|
return util.exportExcel(list, "角色数据");
|
||||||
|
|
@ -74,8 +72,7 @@ public class SysRoleController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||||
@GetMapping(value = "/{roleId}")
|
@GetMapping(value = "/{roleId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long roleId)
|
public AjaxResult getInfo(@PathVariable Long roleId) {
|
||||||
{
|
|
||||||
return AjaxResult.success(roleService.selectRoleById(roleId));
|
return AjaxResult.success(roleService.selectRoleById(roleId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,16 +80,12 @@ public class SysRoleController extends BaseController
|
||||||
* 新增角色
|
* 新增角色
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:add')")
|
@PreAuthorize("@ss.hasPermi('system:role:add')")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
@Log(title = "角色管理" , businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysRole role)
|
public AjaxResult add(@Validated @RequestBody SysRole role) {
|
||||||
{
|
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||||
}
|
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
|
||||||
else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||||
}
|
}
|
||||||
role.setCreateBy(SecurityUtils.getUserId());
|
role.setCreateBy(SecurityUtils.getUserId());
|
||||||
|
|
@ -104,27 +97,21 @@ public class SysRoleController extends BaseController
|
||||||
* 修改保存角色
|
* 修改保存角色
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
@Log(title = "角色管理" , businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysRole role)
|
public AjaxResult edit(@Validated @RequestBody SysRole role) {
|
||||||
{
|
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
|
||||||
{
|
|
||||||
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||||
}
|
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
|
||||||
else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||||
}
|
}
|
||||||
role.setUpdateBy(SecurityUtils.getUserId());
|
role.setUpdateBy(SecurityUtils.getUserId());
|
||||||
|
|
||||||
if (roleService.updateRole(role) > 0)
|
if (roleService.updateRole(role) > 0) {
|
||||||
{
|
|
||||||
// 更新缓存用户权限
|
// 更新缓存用户权限
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin())
|
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) {
|
||||||
{
|
|
||||||
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
|
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
|
||||||
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
|
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
|
||||||
tokenService.setLoginUser(loginUser);
|
tokenService.setLoginUser(loginUser);
|
||||||
|
|
@ -138,10 +125,9 @@ public class SysRoleController extends BaseController
|
||||||
* 修改保存数据权限
|
* 修改保存数据权限
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
@Log(title = "角色管理" , businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/dataScope")
|
@PutMapping("/dataScope")
|
||||||
public AjaxResult dataScope(@RequestBody SysRole role)
|
public AjaxResult dataScope(@RequestBody SysRole role) {
|
||||||
{
|
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
return toAjax(roleService.authDataScope(role));
|
return toAjax(roleService.authDataScope(role));
|
||||||
}
|
}
|
||||||
|
|
@ -150,10 +136,9 @@ public class SysRoleController extends BaseController
|
||||||
* 状态修改
|
* 状态修改
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
@Log(title = "角色管理" , businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/changeStatus")
|
@PutMapping("/changeStatus")
|
||||||
public AjaxResult changeStatus(@RequestBody SysRole role)
|
public AjaxResult changeStatus(@RequestBody SysRole role) {
|
||||||
{
|
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
role.setUpdateBy(SecurityUtils.getUserId());
|
role.setUpdateBy(SecurityUtils.getUserId());
|
||||||
return toAjax(roleService.updateRoleStatus(role));
|
return toAjax(roleService.updateRoleStatus(role));
|
||||||
|
|
@ -163,10 +148,9 @@ public class SysRoleController extends BaseController
|
||||||
* 删除角色
|
* 删除角色
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:remove')")
|
@PreAuthorize("@ss.hasPermi('system:role:remove')")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
@Log(title = "角色管理" , businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{roleIds}")
|
@DeleteMapping("/{roleIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] roleIds)
|
public AjaxResult remove(@PathVariable Long[] roleIds) {
|
||||||
{
|
|
||||||
return toAjax(roleService.deleteRoleByIds(roleIds));
|
return toAjax(roleService.deleteRoleByIds(roleIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,8 +159,7 @@ public class SysRoleController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||||
@GetMapping("/optionselect")
|
@GetMapping("/optionselect")
|
||||||
public AjaxResult optionselect()
|
public AjaxResult optionselect() {
|
||||||
{
|
|
||||||
return AjaxResult.success(roleService.selectRoleAll());
|
return AjaxResult.success(roleService.selectRoleAll());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.hchyun.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -39,8 +40,7 @@ import com.hchyun.system.service.ISysUserService;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/user")
|
@RequestMapping("/system/user")
|
||||||
public class SysUserController extends BaseController
|
public class SysUserController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserService userService;
|
private ISysUserService userService;
|
||||||
|
|
||||||
|
|
@ -58,28 +58,25 @@ public class SysUserController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:list')")
|
@PreAuthorize("@ss.hasPermi('system:user:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(SysUser user)
|
public TableDataInfo list(SysUser user) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<SysUser> list = userService.selectUserList(user);
|
List<SysUser> list = userService.selectUserList(user);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
@Log(title = "用户管理" , businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:export')")
|
@PreAuthorize("@ss.hasPermi('system:user:export')")
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public AjaxResult export(SysUser user)
|
public AjaxResult export(SysUser user) {
|
||||||
{
|
|
||||||
List<SysUser> list = userService.selectUserList(user);
|
List<SysUser> list = userService.selectUserList(user);
|
||||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||||
return util.exportExcel(list, "用户数据");
|
return util.exportExcel(list, "用户数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
@Log(title = "用户管理" , businessType = BusinessType.IMPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:import')")
|
@PreAuthorize("@ss.hasPermi('system:user:import')")
|
||||||
@PostMapping("/importData")
|
@PostMapping("/importData")
|
||||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
|
||||||
{
|
|
||||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||||
List<SysUser> userList = util.importExcel(file.getInputStream());
|
List<SysUser> userList = util.importExcel(file.getInputStream());
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
|
|
@ -89,8 +86,7 @@ public class SysUserController extends BaseController
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/importTemplate")
|
@GetMapping("/importTemplate")
|
||||||
public AjaxResult importTemplate()
|
public AjaxResult importTemplate() {
|
||||||
{
|
|
||||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||||
return util.importTemplateExcel("用户数据");
|
return util.importTemplateExcel("用户数据");
|
||||||
}
|
}
|
||||||
|
|
@ -99,18 +95,16 @@ public class SysUserController extends BaseController
|
||||||
* 根据用户编号获取详细信息
|
* 根据用户编号获取详细信息
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||||
@GetMapping(value = { "/", "/{userId}" })
|
@GetMapping(value = {"/" , "/{userId}"})
|
||||||
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
|
public AjaxResult getInfo(@PathVariable(value = "userId" , required = false) Long userId) {
|
||||||
{
|
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
List<SysRole> roles = roleService.selectRoleAll();
|
List<SysRole> roles = roleService.selectRoleAll();
|
||||||
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
ajax.put("roles" , SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||||
ajax.put("posts", postService.selectPostAll());
|
ajax.put("posts" , postService.selectPostAll());
|
||||||
if (StringUtils.isNotNull(userId))
|
if (StringUtils.isNotNull(userId)) {
|
||||||
{
|
|
||||||
ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
|
ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
|
||||||
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
ajax.put("postIds" , postService.selectPostListByUserId(userId));
|
||||||
ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
|
ajax.put("roleIds" , roleService.selectRoleListByUserId(userId));
|
||||||
}
|
}
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
}
|
||||||
|
|
@ -119,20 +113,14 @@ public class SysUserController extends BaseController
|
||||||
* 新增用户
|
* 新增用户
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:add')")
|
@PreAuthorize("@ss.hasPermi('system:user:add')")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
@Log(title = "用户管理" , businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysUser user)
|
public AjaxResult add(@Validated @RequestBody SysUser user) {
|
||||||
{
|
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName()))) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName())))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||||
}
|
} else if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
||||||
else if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
}
|
} else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||||
else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
}
|
}
|
||||||
user.setCreateBy(SecurityUtils.getUserId());
|
user.setCreateBy(SecurityUtils.getUserId());
|
||||||
|
|
@ -144,17 +132,13 @@ public class SysUserController extends BaseController
|
||||||
* 修改用户
|
* 修改用户
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
@Log(title = "用户管理" , businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
public AjaxResult edit(@Validated @RequestBody SysUser user) {
|
||||||
{
|
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
||||||
{
|
|
||||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
}
|
} else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||||
else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
}
|
}
|
||||||
user.setUpdateBy(SecurityUtils.getUserId());
|
user.setUpdateBy(SecurityUtils.getUserId());
|
||||||
|
|
@ -165,10 +149,9 @@ public class SysUserController extends BaseController
|
||||||
* 删除用户
|
* 删除用户
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:remove')")
|
@PreAuthorize("@ss.hasPermi('system:user:remove')")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
@Log(title = "用户管理" , businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{userIds}")
|
@DeleteMapping("/{userIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] userIds)
|
public AjaxResult remove(@PathVariable Long[] userIds) {
|
||||||
{
|
|
||||||
return toAjax(userService.deleteUserByIds(userIds));
|
return toAjax(userService.deleteUserByIds(userIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,10 +159,9 @@ public class SysUserController extends BaseController
|
||||||
* 重置密码
|
* 重置密码
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
|
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
@Log(title = "用户管理" , businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/resetPwd")
|
@PutMapping("/resetPwd")
|
||||||
public AjaxResult resetPwd(@RequestBody SysUser user)
|
public AjaxResult resetPwd(@RequestBody SysUser user) {
|
||||||
{
|
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||||
user.setUpdateBy(SecurityUtils.getUserId());
|
user.setUpdateBy(SecurityUtils.getUserId());
|
||||||
|
|
@ -190,10 +172,9 @@ public class SysUserController extends BaseController
|
||||||
* 状态修改
|
* 状态修改
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
@Log(title = "用户管理" , businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/changeStatus")
|
@PutMapping("/changeStatus")
|
||||||
public AjaxResult changeStatus(@RequestBody SysUser user)
|
public AjaxResult changeStatus(@RequestBody SysUser user) {
|
||||||
{
|
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
user.setUpdateBy(SecurityUtils.getUserId());
|
user.setUpdateBy(SecurityUtils.getUserId());
|
||||||
return toAjax(userService.updateUserStatus(user));
|
return toAjax(userService.updateUserStatus(user));
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,10 @@ import com.hchyun.common.core.controller.BaseController;
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/tool/swagger")
|
@RequestMapping("/tool/swagger")
|
||||||
public class SwaggerController extends BaseController
|
public class SwaggerController extends BaseController {
|
||||||
{
|
|
||||||
@PreAuthorize("@ss.hasPermi('tool:swagger:view')")
|
@PreAuthorize("@ss.hasPermi('tool:swagger:view')")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String index()
|
public String index() {
|
||||||
{
|
|
||||||
return redirect("/swagger-ui.html");
|
return redirect("/swagger-ui.html");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
|
@ -28,60 +29,50 @@ import io.swagger.annotations.ApiOperation;
|
||||||
@Api("用户信息管理")
|
@Api("用户信息管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/test/user")
|
@RequestMapping("/test/user")
|
||||||
public class TestController extends BaseController
|
public class TestController extends BaseController {
|
||||||
{
|
|
||||||
private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
|
private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
|
||||||
|
|
||||||
{
|
{
|
||||||
users.put(1, new UserEntity(1, "admin", "admin123", "15888888888"));
|
users.put(1, new UserEntity(1, "admin" , "admin123" , "15888888888"));
|
||||||
users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
|
users.put(2, new UserEntity(2, "ry" , "admin123" , "15666666666"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("获取用户列表")
|
@ApiOperation("获取用户列表")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult userList()
|
public AjaxResult userList() {
|
||||||
{
|
|
||||||
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
|
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
|
||||||
return AjaxResult.success(userList);
|
return AjaxResult.success(userList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("获取用户详细")
|
@ApiOperation("获取用户详细")
|
||||||
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
|
@ApiImplicitParam(name = "userId" , value = "用户ID" , required = true, dataType = "int" , paramType = "path")
|
||||||
@GetMapping("/{userId}")
|
@GetMapping("/{userId}")
|
||||||
public AjaxResult getUser(@PathVariable Integer userId)
|
public AjaxResult getUser(@PathVariable Integer userId) {
|
||||||
{
|
if (!users.isEmpty() && users.containsKey(userId)) {
|
||||||
if (!users.isEmpty() && users.containsKey(userId))
|
|
||||||
{
|
|
||||||
return AjaxResult.success(users.get(userId));
|
return AjaxResult.success(users.get(userId));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return AjaxResult.error("用户不存在");
|
return AjaxResult.error("用户不存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("新增用户")
|
@ApiOperation("新增用户")
|
||||||
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
|
@ApiImplicitParam(name = "userEntity" , value = "新增用户信息" , dataType = "UserEntity")
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
public AjaxResult save(UserEntity user)
|
public AjaxResult save(UserEntity user) {
|
||||||
{
|
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
|
||||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("用户ID不能为空");
|
return AjaxResult.error("用户ID不能为空");
|
||||||
}
|
}
|
||||||
return AjaxResult.success(users.put(user.getUserId(), user));
|
return AjaxResult.success(users.put(user.getUserId(), user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("更新用户")
|
@ApiOperation("更新用户")
|
||||||
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
|
@ApiImplicitParam(name = "userEntity" , value = "新增用户信息" , dataType = "UserEntity")
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
public AjaxResult update(UserEntity user)
|
public AjaxResult update(UserEntity user) {
|
||||||
{
|
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
|
||||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("用户ID不能为空");
|
return AjaxResult.error("用户ID不能为空");
|
||||||
}
|
}
|
||||||
if (users.isEmpty() || !users.containsKey(user.getUserId()))
|
if (users.isEmpty() || !users.containsKey(user.getUserId())) {
|
||||||
{
|
|
||||||
return AjaxResult.error("用户不存在");
|
return AjaxResult.error("用户不存在");
|
||||||
}
|
}
|
||||||
users.remove(user.getUserId());
|
users.remove(user.getUserId());
|
||||||
|
|
@ -89,25 +80,20 @@ public class TestController extends BaseController
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("删除用户信息")
|
@ApiOperation("删除用户信息")
|
||||||
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
|
@ApiImplicitParam(name = "userId" , value = "用户ID" , required = true, dataType = "int" , paramType = "path")
|
||||||
@DeleteMapping("/{userId}")
|
@DeleteMapping("/{userId}")
|
||||||
public AjaxResult delete(@PathVariable Integer userId)
|
public AjaxResult delete(@PathVariable Integer userId) {
|
||||||
{
|
if (!users.isEmpty() && users.containsKey(userId)) {
|
||||||
if (!users.isEmpty() && users.containsKey(userId))
|
|
||||||
{
|
|
||||||
users.remove(userId);
|
users.remove(userId);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return AjaxResult.error("用户不存在");
|
return AjaxResult.error("用户不存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiModel("用户实体")
|
@ApiModel("用户实体")
|
||||||
class UserEntity
|
class UserEntity {
|
||||||
{
|
|
||||||
@ApiModelProperty("用户ID")
|
@ApiModelProperty("用户ID")
|
||||||
private Integer userId;
|
private Integer userId;
|
||||||
|
|
||||||
|
|
@ -120,56 +106,46 @@ class UserEntity
|
||||||
@ApiModelProperty("用户手机")
|
@ApiModelProperty("用户手机")
|
||||||
private String mobile;
|
private String mobile;
|
||||||
|
|
||||||
public UserEntity()
|
public UserEntity() {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserEntity(Integer userId, String username, String password, String mobile)
|
public UserEntity(Integer userId, String username, String password, String mobile) {
|
||||||
{
|
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
this.mobile = mobile;
|
this.mobile = mobile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getUserId()
|
public Integer getUserId() {
|
||||||
{
|
|
||||||
return userId;
|
return userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserId(Integer userId)
|
public void setUserId(Integer userId) {
|
||||||
{
|
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsername()
|
public String getUsername() {
|
||||||
{
|
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsername(String username)
|
public void setUsername(String username) {
|
||||||
{
|
|
||||||
this.username = username;
|
this.username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPassword()
|
public String getPassword() {
|
||||||
{
|
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPassword(String password)
|
public void setPassword(String password) {
|
||||||
{
|
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMobile()
|
public String getMobile() {
|
||||||
{
|
|
||||||
return mobile;
|
return mobile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMobile(String mobile)
|
public void setMobile(String mobile) {
|
||||||
{
|
|
||||||
this.mobile = mobile;
|
this.mobile = mobile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,10 +56,11 @@ public class SwaggerConfig
|
||||||
// 设置哪些接口暴露给Swagger展示
|
// 设置哪些接口暴露给Swagger展示
|
||||||
.select()
|
.select()
|
||||||
// 扫描所有有注解的api,用这种方式更灵活
|
// 扫描所有有注解的api,用这种方式更灵活
|
||||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
// .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||||
// 扫描指定包中的swagger注解
|
// 扫描指定包中的swagger注解
|
||||||
// .apis(RequestHandlerSelectors.basePackage("com.hchyun.project.tool.swagger"))
|
// .apis(RequestHandlerSelectors.basePackage("com.hchyun.project.tool.swagger"))
|
||||||
// 扫描所有 .apis(RequestHandlerSelectors.any())
|
// 扫描所有
|
||||||
|
.apis(RequestHandlerSelectors.any())
|
||||||
.paths(PathSelectors.any())
|
.paths(PathSelectors.any())
|
||||||
.build()
|
.build()
|
||||||
/* 设置安全模式,swagger可以设置访问token */
|
/* 设置安全模式,swagger可以设置访问token */
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ hchyun:
|
||||||
# 实例演示开关
|
# 实例演示开关
|
||||||
demoEnabled: true
|
demoEnabled: true
|
||||||
# 文件路径 示例( Windows配置D:/hchyun/uploadPath,Linux配置 /home/hchyun/uploadPath)
|
# 文件路径 示例( Windows配置D:/hchyun/uploadPath,Linux配置 /home/hchyun/uploadPath)
|
||||||
profile: /home/hchyun/uploadPath
|
profile: F:/hchyun/uploadPath
|
||||||
# 获取ip地址开关
|
# 获取ip地址开关
|
||||||
addressEnabled: false
|
addressEnabled: false
|
||||||
# 验证码类型 math 数组计算 char 字符验证
|
# 验证码类型 math 数组计算 char 字符验证
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.hchyun.common.core.controller;
|
||||||
import java.beans.PropertyEditorSupport;
|
import java.beans.PropertyEditorSupport;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.bind.WebDataBinder;
|
import org.springframework.web.bind.WebDataBinder;
|
||||||
|
|
@ -23,22 +24,18 @@ import com.hchyun.common.utils.sql.SqlUtil;
|
||||||
*
|
*
|
||||||
* @author hchyun
|
* @author hchyun
|
||||||
*/
|
*/
|
||||||
public class BaseController
|
public class BaseController {
|
||||||
{
|
|
||||||
protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
|
protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
||||||
*/
|
*/
|
||||||
@InitBinder
|
@InitBinder
|
||||||
public void initBinder(WebDataBinder binder)
|
public void initBinder(WebDataBinder binder) {
|
||||||
{
|
|
||||||
// Date 类型转换
|
// Date 类型转换
|
||||||
binder.registerCustomEditor(Date.class, new PropertyEditorSupport()
|
binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public void setAsText(String text)
|
public void setAsText(String text) {
|
||||||
{
|
|
||||||
setValue(DateUtils.parseDate(text));
|
setValue(DateUtils.parseDate(text));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -47,13 +44,11 @@ public class BaseController
|
||||||
/**
|
/**
|
||||||
* 设置请求分页数据
|
* 设置请求分页数据
|
||||||
*/
|
*/
|
||||||
protected void startPage()
|
protected void startPage() {
|
||||||
{
|
|
||||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
Integer pageNum = pageDomain.getPageNum();
|
Integer pageNum = pageDomain.getPageNum();
|
||||||
Integer pageSize = pageDomain.getPageSize();
|
Integer pageSize = pageDomain.getPageSize();
|
||||||
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
|
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
|
||||||
{
|
|
||||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||||
PageHelper.startPage(pageNum, pageSize, orderBy);
|
PageHelper.startPage(pageNum, pageSize, orderBy);
|
||||||
}
|
}
|
||||||
|
|
@ -62,9 +57,8 @@ public class BaseController
|
||||||
/**
|
/**
|
||||||
* 响应请求分页数据
|
* 响应请求分页数据
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
protected TableDataInfo getDataTable(List<?> list)
|
protected TableDataInfo getDataTable(List<?> list) {
|
||||||
{
|
|
||||||
TableDataInfo rspData = new TableDataInfo();
|
TableDataInfo rspData = new TableDataInfo();
|
||||||
rspData.setCode(HttpStatus.SUCCESS);
|
rspData.setCode(HttpStatus.SUCCESS);
|
||||||
rspData.setMsg("查询成功");
|
rspData.setMsg("查询成功");
|
||||||
|
|
@ -79,16 +73,15 @@ public class BaseController
|
||||||
* @param rows 影响行数
|
* @param rows 影响行数
|
||||||
* @return 操作结果
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
protected AjaxResult toAjax(int rows)
|
protected AjaxResult toAjax(int rows) {
|
||||||
{
|
|
||||||
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面跳转
|
* 页面跳转
|
||||||
*/
|
*/
|
||||||
public String redirect(String url)
|
public String redirect(String url) {
|
||||||
{
|
System.out.println(StringUtils.format("redirect:{}", url));
|
||||||
return StringUtils.format("redirect:{}", url);
|
return StringUtils.format("redirect:{}", url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,12 @@ import com.hchyun.framework.interceptor.RepeatSubmitInterceptor;
|
||||||
* @author hchyun
|
* @author hchyun
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class ResourcesConfig implements WebMvcConfigurer
|
public class ResourcesConfig implements WebMvcConfigurer {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RepeatSubmitInterceptor repeatSubmitInterceptor;
|
private RepeatSubmitInterceptor repeatSubmitInterceptor;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry)
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
{
|
|
||||||
/** 本地文件上传路径 */
|
/** 本地文件上传路径 */
|
||||||
registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + HchYunConfig.getProfile() + "/");
|
registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + HchYunConfig.getProfile() + "/");
|
||||||
|
|
||||||
|
|
@ -39,8 +37,7 @@ public class ResourcesConfig implements WebMvcConfigurer
|
||||||
* 自定义拦截规则
|
* 自定义拦截规则
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addInterceptors(InterceptorRegistry registry)
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
{
|
|
||||||
registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**");
|
registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,8 +45,7 @@ public class ResourcesConfig implements WebMvcConfigurer
|
||||||
* 跨域配置
|
* 跨域配置
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public CorsFilter corsFilter()
|
public CorsFilter corsFilter() {
|
||||||
{
|
|
||||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||||
CorsConfiguration config = new CorsConfiguration();
|
CorsConfiguration config = new CorsConfiguration();
|
||||||
config.setAllowCredentials(true);
|
config.setAllowCredentials(true);
|
||||||
|
|
@ -60,7 +56,7 @@ public class ResourcesConfig implements WebMvcConfigurer
|
||||||
// 设置访问源请求方法
|
// 设置访问源请求方法
|
||||||
config.addAllowedMethod("*");
|
config.addAllowedMethod("*");
|
||||||
// 对接口配置跨域设置
|
// 对接口配置跨域设置
|
||||||
source.registerCorsConfiguration("/**", config);
|
source.registerCorsConfiguration("/**" , config);
|
||||||
return new CorsFilter(source);
|
return new CorsFilter(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -49,7 +49,7 @@ public class ${ClassName}ServiceImpl implements ${ClassName}Service {
|
||||||
public ServerResult<${ClassName}> select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField}) {
|
public ServerResult<${ClassName}> select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField}) {
|
||||||
try {
|
try {
|
||||||
${ClassName} ${className} = ${className}Dao.select${ClassName}ById(${pkColumn.javaField});
|
${ClassName} ${className} = ${className}Dao.select${ClassName}ById(${pkColumn.javaField});
|
||||||
if (stu != null){
|
if (${className} != null){
|
||||||
return new ServerResult<${ClassName}>(true,${className});
|
return new ServerResult<${ClassName}>(true,${className});
|
||||||
}else {
|
}else {
|
||||||
return new ServerResult<${ClassName}>(false, ReturnConstants.RESULT_EMPTY);
|
return new ServerResult<${ClassName}>(false, ReturnConstants.RESULT_EMPTY);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,186 @@
|
||||||
|
package com.hchyun.test.controller;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
||||||
|
import com.hchyun.common.constant.ReturnConstants;
|
||||||
|
import com.hchyun.common.core.controller.HcyBaseController;
|
||||||
|
import com.hchyun.common.utils.ServerResult;
|
||||||
|
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;
|
||||||
|
import com.hchyun.test.entity.Results;
|
||||||
|
import com.hchyun.test.service.ResultsService;
|
||||||
|
import com.hchyun.common.utils.poi.ExcelUtil;
|
||||||
|
import com.hchyun.common.core.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成绩Controller
|
||||||
|
*
|
||||||
|
* @author hchyun
|
||||||
|
* @date 2021-01-23
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/test/results")
|
||||||
|
public class ResultsController extends HcyBaseController {
|
||||||
|
protected final Logger logger = LoggerFactory.getLogger(ResultsController.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ResultsService resultsService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询成绩列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('test:results:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Serializable list(Results results) {
|
||||||
|
try {
|
||||||
|
startPage();
|
||||||
|
ServerResult<List<Results>> serverResult = resultsService.selectResultsList(results);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出成绩列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('test:results:export')")
|
||||||
|
@Log(title = "成绩", businessType = BusinessType.EXPORT)
|
||||||
|
@GetMapping("/export")
|
||||||
|
public AjaxResult export(Results results) {
|
||||||
|
try {
|
||||||
|
ServerResult<List<Results>> serverResult = resultsService.selectResultsList(results);
|
||||||
|
ExcelUtil<Results> util = new ExcelUtil<Results>(Results. class);
|
||||||
|
if (serverResult.isStart()) {
|
||||||
|
return util.exportExcel(serverResult.getData(), "results");
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error(serverResult.getMsg());
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取成绩详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('test:results:query')")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||||
|
try {
|
||||||
|
ServerResult<Results> serverResult = resultsService.selectResultsById(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增成绩
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('test:results:add')")
|
||||||
|
@Log(title = "成绩", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody Results results) {
|
||||||
|
if (results.getJava() == null || results.getJava()<0) {
|
||||||
|
return AjaxResult.error("java成绩不能为空!");
|
||||||
|
}
|
||||||
|
if (results.getImages() == null || results.getImages().equals("")) {
|
||||||
|
return AjaxResult.error("图片路径不能为空!");
|
||||||
|
}
|
||||||
|
if (results.getFile() == null || results.getFile().equals("")) {
|
||||||
|
return AjaxResult.error("文件路径不能为空!");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ServerResult<Integer> serverResult = resultsService.insertResults(results);
|
||||||
|
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('test:results:edit')")
|
||||||
|
@Log(title = "成绩", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody Results results) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (results.getJava() == null || results.getJava()<0) {
|
||||||
|
return AjaxResult.error("java成绩不能为空!");
|
||||||
|
}
|
||||||
|
if (results.getImages() == null || results.getImages().equals("")) {
|
||||||
|
return AjaxResult.error("图片路径不能为空!");
|
||||||
|
}
|
||||||
|
if (results.getFile() == null || results.getFile().equals("")) {
|
||||||
|
return AjaxResult.error("文件路径不能为空!");
|
||||||
|
}
|
||||||
|
ServerResult<Integer> serverResult = resultsService.updateResults(results);
|
||||||
|
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('test:results: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 = resultsService.deleteResultsByIds(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -32,7 +32,7 @@ import com.hchyun.common.core.page.TableDataInfo;
|
||||||
* 学生Controller
|
* 学生Controller
|
||||||
*
|
*
|
||||||
* @author hchyun
|
* @author hchyun
|
||||||
* @date 2021-01-22
|
* @date 2021-01-23
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/test/stu")
|
@RequestMapping("/test/stu")
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.hchyun.test.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.hchyun.test.entity.Results;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成绩Mapper接口
|
||||||
|
*
|
||||||
|
* @author hchyun
|
||||||
|
* @date 2021-01-23
|
||||||
|
*/
|
||||||
|
public interface ResultsDao
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询成绩
|
||||||
|
*
|
||||||
|
* @param id 成绩ID
|
||||||
|
* @return 成绩
|
||||||
|
*/
|
||||||
|
Results selectResultsById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询成绩列表
|
||||||
|
*
|
||||||
|
* @param results 成绩
|
||||||
|
* @return 成绩集合
|
||||||
|
*/
|
||||||
|
List<Results> selectResultsList(Results results);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增成绩
|
||||||
|
*
|
||||||
|
* @param results 成绩
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int insertResults(Results results);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改成绩
|
||||||
|
*
|
||||||
|
* @param results 成绩
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int updateResults(Results results);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除成绩
|
||||||
|
*
|
||||||
|
* @param id 成绩ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteResultsById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除成绩
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteResultsByIds(Long[] ids);
|
||||||
|
}
|
||||||
|
|
@ -8,7 +8,7 @@ import com.hchyun.test.entity.Results;
|
||||||
* 学生Mapper接口
|
* 学生Mapper接口
|
||||||
*
|
*
|
||||||
* @author hchyun
|
* @author hchyun
|
||||||
* @date 2021-01-22
|
* @date 2021-01-23
|
||||||
*/
|
*/
|
||||||
public interface StuDao
|
public interface StuDao
|
||||||
{
|
{
|
||||||
|
|
@ -66,7 +66,7 @@ public interface StuDao
|
||||||
* @param customerIds 需要删除的数据ID
|
* @param customerIds 需要删除的数据ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int deleteResultsByIds(Long[] ids);
|
int deleteResultsBySIds(Long[] ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量新增成绩
|
* 批量新增成绩
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
* 成绩对象 sys_results
|
* 成绩对象 sys_results
|
||||||
*
|
*
|
||||||
* @author hchyun
|
* @author hchyun
|
||||||
* @date 2021-01-22
|
* @date 2021-01-23
|
||||||
*/
|
*/
|
||||||
public class Results extends BaseEntity
|
public class Results extends BaseEntity
|
||||||
{
|
{
|
||||||
|
|
@ -26,6 +26,14 @@ public class Results extends BaseEntity
|
||||||
@Excel(name = "java成绩")
|
@Excel(name = "java成绩")
|
||||||
private Long java;
|
private Long java;
|
||||||
|
|
||||||
|
/** 图片路径 */
|
||||||
|
@Excel(name = "图片路径")
|
||||||
|
private String images;
|
||||||
|
|
||||||
|
/** 文件路径 */
|
||||||
|
@Excel(name = "文件路径")
|
||||||
|
private String file;
|
||||||
|
|
||||||
public void setId(Long id)
|
public void setId(Long id)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
@ -35,15 +43,15 @@ public class Results extends BaseEntity
|
||||||
{
|
{
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
public void setSId(Long sId)
|
|
||||||
{
|
public Long getsId() {
|
||||||
|
return sId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setsId(Long sId) {
|
||||||
this.sId = sId;
|
this.sId = sId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getSId()
|
|
||||||
{
|
|
||||||
return sId;
|
|
||||||
}
|
|
||||||
public void setJava(Long java)
|
public void setJava(Long java)
|
||||||
{
|
{
|
||||||
this.java = java;
|
this.java = java;
|
||||||
|
|
@ -53,13 +61,33 @@ public class Results extends BaseEntity
|
||||||
{
|
{
|
||||||
return java;
|
return java;
|
||||||
}
|
}
|
||||||
|
public void setImages(String images)
|
||||||
|
{
|
||||||
|
this.images = images;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImages()
|
||||||
|
{
|
||||||
|
return images;
|
||||||
|
}
|
||||||
|
public void setFile(String file)
|
||||||
|
{
|
||||||
|
this.file = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFile()
|
||||||
|
{
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
.append("id", getId())
|
.append("id", getId())
|
||||||
.append("sId", getSId())
|
.append("sId", getsId())
|
||||||
.append("java", getJava())
|
.append("java", getJava())
|
||||||
|
.append("images", getImages())
|
||||||
|
.append("file", getFile())
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
* 学生对象 sys_stu
|
* 学生对象 sys_stu
|
||||||
*
|
*
|
||||||
* @author hchyun
|
* @author hchyun
|
||||||
* @date 2021-01-22
|
* @date 2021-01-23
|
||||||
*/
|
*/
|
||||||
public class Stu extends BaseEntity
|
public class Stu extends BaseEntity
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.hchyun.test.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.hchyun.common.utils.ServerResult;
|
||||||
|
import com.hchyun.test.entity.Results;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成绩Service接口
|
||||||
|
*
|
||||||
|
* @author hchyun
|
||||||
|
* @date 2021-01-23
|
||||||
|
*/
|
||||||
|
public interface ResultsService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询成绩
|
||||||
|
*
|
||||||
|
* @param id 成绩ID
|
||||||
|
* @return 成绩
|
||||||
|
*/
|
||||||
|
ServerResult<Results> selectResultsById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询成绩列表
|
||||||
|
*
|
||||||
|
* @param results 成绩
|
||||||
|
* @return 成绩集合
|
||||||
|
*/
|
||||||
|
ServerResult<List<Results>> selectResultsList(Results results);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增成绩
|
||||||
|
*
|
||||||
|
* @param results 成绩
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
ServerResult<Integer> insertResults(Results results);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改成绩
|
||||||
|
*
|
||||||
|
* @param results 成绩
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
ServerResult<Integer> updateResults(Results results);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除成绩
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的成绩ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
ServerResult<Integer> deleteResultsByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除成绩信息
|
||||||
|
*
|
||||||
|
* @param id 成绩ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
ServerResult<Integer> deleteResultsById(Long id);
|
||||||
|
}
|
||||||
|
|
@ -9,7 +9,7 @@ import com.hchyun.test.entity.Stu;
|
||||||
* 学生Service接口
|
* 学生Service接口
|
||||||
*
|
*
|
||||||
* @author hchyun
|
* @author hchyun
|
||||||
* @date 2021-01-22
|
* @date 2021-01-23
|
||||||
*/
|
*/
|
||||||
public interface StuService
|
public interface StuService
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,153 @@
|
||||||
|
package com.hchyun.test.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.hchyun.common.constant.ReturnConstants;
|
||||||
|
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.test.dao.ResultsDao;
|
||||||
|
import com.hchyun.test.entity.Results;
|
||||||
|
import com.hchyun.test.service.ResultsService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成绩Service业务层处理
|
||||||
|
*
|
||||||
|
* @author hchyun
|
||||||
|
* @date 2021-01-23
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ResultsServiceImpl implements ResultsService {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(ResultsServiceImpl.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ResultsDao resultsDao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询成绩
|
||||||
|
*
|
||||||
|
* @param id 成绩ID
|
||||||
|
* @return 成绩
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ServerResult<Results> selectResultsById(Long id) {
|
||||||
|
try {
|
||||||
|
Results results = resultsDao.selectResultsById(id);
|
||||||
|
if (results != null){
|
||||||
|
return new ServerResult<Results>(true,results);
|
||||||
|
}else {
|
||||||
|
return new ServerResult<Results>(false, ReturnConstants.RESULT_EMPTY);
|
||||||
|
}
|
||||||
|
}catch (RuntimeException e){
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return new ServerResult<Results>(false,ReturnConstants.DB_EX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询成绩列表
|
||||||
|
*
|
||||||
|
* @param results 成绩
|
||||||
|
* @return 成绩
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ServerResult<List<Results>> selectResultsList(Results results) {
|
||||||
|
try {
|
||||||
|
List<Results> resultsList = resultsDao.selectResultsList(results);
|
||||||
|
if (resultsList.size()>0){
|
||||||
|
return new ServerResult<List<Results>>(true,resultsList);
|
||||||
|
}else {
|
||||||
|
return new ServerResult<List<Results>>(false,ReturnConstants.RESULT_EMPTY);
|
||||||
|
}
|
||||||
|
}catch (RuntimeException e){
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return new ServerResult<List<Results>>(false,ReturnConstants.DB_EX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增成绩
|
||||||
|
*
|
||||||
|
* @param results 成绩
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ServerResult<Integer> insertResults(Results results) {
|
||||||
|
try {
|
||||||
|
Integer renewal = resultsDao.insertResults(results);
|
||||||
|
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 results 成绩
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ServerResult<Integer> updateResults(Results results) {
|
||||||
|
try {
|
||||||
|
Integer renewal = resultsDao.updateResults(results);
|
||||||
|
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> deleteResultsByIds(Long[] ids) {
|
||||||
|
try {
|
||||||
|
Integer renewal = resultsDao.deleteResultsByIds(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> deleteResultsById(Long id) {
|
||||||
|
try {
|
||||||
|
Integer renewal = resultsDao.deleteResultsById(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,12 +5,13 @@ import java.util.List;
|
||||||
import com.hchyun.common.constant.ReturnConstants;
|
import com.hchyun.common.constant.ReturnConstants;
|
||||||
import com.hchyun.common.utils.DateUtils;
|
import com.hchyun.common.utils.DateUtils;
|
||||||
import com.hchyun.common.utils.SecurityUtils;
|
import com.hchyun.common.utils.SecurityUtils;
|
||||||
|
import com.hchyun.common.utils.DateUtils;
|
||||||
|
import com.hchyun.common.utils.SecurityUtils;
|
||||||
import com.hchyun.common.utils.ServerResult;
|
import com.hchyun.common.utils.ServerResult;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import com.hchyun.common.utils.StringUtils;
|
import com.hchyun.common.utils.StringUtils;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
@ -23,7 +24,7 @@ import com.hchyun.test.service.StuService;
|
||||||
* 学生Service业务层处理
|
* 学生Service业务层处理
|
||||||
*
|
*
|
||||||
* @author hchyun
|
* @author hchyun
|
||||||
* @date 2021-01-22
|
* @date 2021-01-23
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class StuServiceImpl implements StuService {
|
public class StuServiceImpl implements StuService {
|
||||||
|
|
@ -42,14 +43,14 @@ public class StuServiceImpl implements StuService {
|
||||||
public ServerResult<Stu> selectStuById(Long id) {
|
public ServerResult<Stu> selectStuById(Long id) {
|
||||||
try {
|
try {
|
||||||
Stu stu = stuDao.selectStuById(id);
|
Stu stu = stuDao.selectStuById(id);
|
||||||
if (stu != null) {
|
if (stu != null){
|
||||||
return new ServerResult<Stu>(true, stu);
|
return new ServerResult<Stu>(true,stu);
|
||||||
} else {
|
}else {
|
||||||
return new ServerResult<Stu>(false, ReturnConstants.RESULT_EMPTY);
|
return new ServerResult<Stu>(false, ReturnConstants.RESULT_EMPTY);
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
}catch (RuntimeException e){
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
return new ServerResult<Stu>(false, ReturnConstants.DB_EX);
|
return new ServerResult<Stu>(false,ReturnConstants.DB_EX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,14 +64,14 @@ public class StuServiceImpl implements StuService {
|
||||||
public ServerResult<List<Stu>> selectStuList(Stu stu) {
|
public ServerResult<List<Stu>> selectStuList(Stu stu) {
|
||||||
try {
|
try {
|
||||||
List<Stu> stuList = stuDao.selectStuList(stu);
|
List<Stu> stuList = stuDao.selectStuList(stu);
|
||||||
if (stuList.size() > 0) {
|
if (stuList.size()>0){
|
||||||
return new ServerResult<List<Stu>>(true, stuList);
|
return new ServerResult<List<Stu>>(true,stuList);
|
||||||
} else {
|
}else {
|
||||||
return new ServerResult<List<Stu>>(false, ReturnConstants.RESULT_EMPTY);
|
return new ServerResult<List<Stu>>(false,ReturnConstants.RESULT_EMPTY);
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
}catch (RuntimeException e){
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
return new ServerResult<List<Stu>>(false, ReturnConstants.DB_EX);
|
return new ServerResult<List<Stu>>(false,ReturnConstants.DB_EX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,16 +87,18 @@ public class StuServiceImpl implements StuService {
|
||||||
try {
|
try {
|
||||||
stu.setCreateTime(DateUtils.getNowDate());
|
stu.setCreateTime(DateUtils.getNowDate());
|
||||||
stu.setCreateBy(SecurityUtils.getUserId());
|
stu.setCreateBy(SecurityUtils.getUserId());
|
||||||
int rows = stuDao.insertStu(stu);
|
int renewal = stuDao.insertStu(stu);
|
||||||
insertResults(stu);
|
if (insertResults(stu)){
|
||||||
if (rows > 0) {
|
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||||
return new ServerResult<Integer>(true, rows);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
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());
|
logger.error(e.getMessage());
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.DB_EX);
|
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,14 +119,14 @@ public class StuServiceImpl implements StuService {
|
||||||
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||||
}
|
}
|
||||||
Integer renewal = stuDao.updateStu(stu);
|
Integer renewal = stuDao.updateStu(stu);
|
||||||
if (renewal > 0) {
|
if (renewal >0){
|
||||||
return new ServerResult<Integer>(true, renewal);
|
return new ServerResult<Integer>(true,renewal);
|
||||||
} else {
|
}else {
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
|
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
}catch (RuntimeException e){
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.DB_EX);
|
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,17 +140,17 @@ public class StuServiceImpl implements StuService {
|
||||||
@Override
|
@Override
|
||||||
public ServerResult<Integer> deleteStuByIds(Long[] ids) {
|
public ServerResult<Integer> deleteStuByIds(Long[] ids) {
|
||||||
try {
|
try {
|
||||||
//todo 批量删除子表数据
|
//批量删除子表数据
|
||||||
stuDao.deleteResultsByIds(ids);
|
stuDao.deleteResultsBySIds(ids);
|
||||||
Integer renewal = stuDao.deleteStuByIds(ids);
|
Integer renewal = stuDao.deleteStuByIds(ids);
|
||||||
if (renewal > 0) {
|
if (renewal >0){
|
||||||
return new ServerResult<Integer>(true, renewal);
|
return new ServerResult<Integer>(true,renewal);
|
||||||
} else {
|
}else {
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
|
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
}catch (RuntimeException e){
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.DB_EX);
|
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -160,17 +163,17 @@ public class StuServiceImpl implements StuService {
|
||||||
@Override
|
@Override
|
||||||
public ServerResult<Integer> deleteStuById(Long id) {
|
public ServerResult<Integer> deleteStuById(Long id) {
|
||||||
try {
|
try {
|
||||||
//todo 删除子表数据
|
//删除子表数据
|
||||||
stuDao.deleteResultsBySId(id);
|
stuDao.deleteResultsBySId(id);
|
||||||
Integer renewal = stuDao.deleteStuById(id);
|
Integer renewal = stuDao.deleteStuById(id);
|
||||||
if (renewal > 0) {
|
if (renewal >0){
|
||||||
return new ServerResult<Integer>(true, renewal);
|
return new ServerResult<Integer>(true,renewal);
|
||||||
} else {
|
}else {
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
|
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
}catch (RuntimeException e){
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.DB_EX);
|
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -184,8 +187,8 @@ public class StuServiceImpl implements StuService {
|
||||||
Long id = stu.getId();
|
Long id = stu.getId();
|
||||||
if (StringUtils.isNotNull(resultsList)) {
|
if (StringUtils.isNotNull(resultsList)) {
|
||||||
List<Results> list = new ArrayList<Results>();
|
List<Results> list = new ArrayList<Results>();
|
||||||
for (Results results : resultsList) {
|
for (Results results : resultsList){
|
||||||
results.setSId(id);
|
results.setsId(id);
|
||||||
list.add(results);
|
list.add(results);
|
||||||
}
|
}
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
<?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.test.dao.ResultsDao">
|
||||||
|
|
||||||
|
<resultMap type="Results" id="ResultsResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="sId" column="s_id" />
|
||||||
|
<result property="java" column="java" />
|
||||||
|
<result property="images" column="images" />
|
||||||
|
<result property="file" column="file" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectResultsVo">
|
||||||
|
select id, s_id, java, images, file from sys_results
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectResultsList" parameterType="Results" resultMap="ResultsResult">
|
||||||
|
<include refid="selectResultsVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="java != null "> and java = #{java}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectResultsById" parameterType="Long" resultMap="ResultsResult">
|
||||||
|
<include refid="selectResultsVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertResults" parameterType="Results" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into sys_results
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="sId != null">s_id,</if>
|
||||||
|
<if test="java != null">java,</if>
|
||||||
|
<if test="images != null and images != ''">images,</if>
|
||||||
|
<if test="file != null and file != ''">file,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="sId != null">#{sId},</if>
|
||||||
|
<if test="java != null">#{java},</if>
|
||||||
|
<if test="images != null and images != ''">#{images},</if>
|
||||||
|
<if test="file != null and file != ''">#{file},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateResults" parameterType="Results">
|
||||||
|
update sys_results
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="sId != null">s_id = #{sId},</if>
|
||||||
|
<if test="java != null">java = #{java},</if>
|
||||||
|
<if test="images != null and images != ''">images = #{images},</if>
|
||||||
|
<if test="file != null and file != ''">file = #{file},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteResultsById" parameterType="Long">
|
||||||
|
delete from sys_results where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteResultsByIds" parameterType="String">
|
||||||
|
delete from sys_results where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE mapper
|
<!DOCTYPE mapper
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.hchyun.test.dao.StuDao">
|
<mapper namespace="com.hchyun.test.dao.StuDao">
|
||||||
|
|
||||||
<resultMap type="Stu" id="StuResult">
|
<resultMap type="Stu" id="StuResult">
|
||||||
|
|
@ -23,6 +23,8 @@
|
||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
<result property="sId" column="s_id" />
|
<result property="sId" column="s_id" />
|
||||||
<result property="java" column="java" />
|
<result property="java" column="java" />
|
||||||
|
<result property="images" column="images" />
|
||||||
|
<result property="file" column="file" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectStuVo">
|
<sql id="selectStuVo">
|
||||||
|
|
@ -41,7 +43,7 @@
|
||||||
|
|
||||||
<select id="selectStuById" parameterType="Long" resultMap="StuResultsResult">
|
<select id="selectStuById" parameterType="Long" resultMap="StuResultsResult">
|
||||||
select a.id, a.name, a.tel, a.email, a.create_time, a.create_by, a.update_time, a.update_by,
|
select a.id, a.name, a.tel, a.email, a.create_time, a.create_by, a.update_time, a.update_by,
|
||||||
b.id, b.s_id, b.java
|
b.id, b.s_id, b.java, b.images, b.file
|
||||||
from sys_stu a
|
from sys_stu a
|
||||||
left join sys_results b on b.s_id = a.id
|
left join sys_results b on b.s_id = a.id
|
||||||
where a.id = #{id}
|
where a.id = #{id}
|
||||||
|
|
@ -50,18 +52,18 @@
|
||||||
<insert id="insertStu" parameterType="Stu" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertStu" parameterType="Stu" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into sys_stu
|
insert into sys_stu
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="name != null">name,</if>
|
<if test="name != null and name != ''">name,</if>
|
||||||
<if test="tel != null">tel,</if>
|
<if test="tel != null">tel,</if>
|
||||||
<if test="email != null">email,</if>
|
<if test="email != null and email != ''">email,</if>
|
||||||
<if test="createTime != null">create_time,</if>
|
<if test="createTime != null">create_time,</if>
|
||||||
<if test="createBy != null">create_by,</if>
|
<if test="createBy != null">create_by,</if>
|
||||||
<if test="updateTime != null">update_time,</if>
|
<if test="updateTime != null">update_time,</if>
|
||||||
<if test="updateBy != null">update_by,</if>
|
<if test="updateBy != null">update_by,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="name != null">#{name},</if>
|
<if test="name != null and name != ''">#{name},</if>
|
||||||
<if test="tel != null">#{tel},</if>
|
<if test="tel != null">#{tel},</if>
|
||||||
<if test="email != null">#{email},</if>
|
<if test="email != null and email != ''">#{email},</if>
|
||||||
<if test="createTime != null">#{createTime},</if>
|
<if test="createTime != null">#{createTime},</if>
|
||||||
<if test="createBy != null">#{createBy},</if>
|
<if test="createBy != null">#{createBy},</if>
|
||||||
<if test="updateTime != null">#{updateTime},</if>
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
|
@ -72,9 +74,9 @@
|
||||||
<update id="updateStu" parameterType="Stu">
|
<update id="updateStu" parameterType="Stu">
|
||||||
update sys_stu
|
update sys_stu
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
<if test="name != null">name = #{name},</if>
|
<if test="name != null and name != ''">name = #{name},</if>
|
||||||
<if test="tel != null">tel = #{tel},</if>
|
<if test="tel != null">tel = #{tel},</if>
|
||||||
<if test="email != null">email = #{email},</if>
|
<if test="email != null and email != ''">email = #{email},</if>
|
||||||
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
|
@ -106,9 +108,9 @@
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<insert id="batchResults">
|
<insert id="batchResults">
|
||||||
insert into sys_results( s_id, java) values
|
insert into sys_results(s_id,java,images,file) values
|
||||||
<foreach item="item" index="index" collection="list" separator=",">
|
<foreach item="item" index="index" collection="list" separator=",">
|
||||||
( #{item.sId}, #{item.java})
|
(#{item.sId},#{item.java},#{item.images},#{item.file})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue