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成绩" />
|
||||
</template>
|
||||
</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-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
|
|
@ -215,6 +225,17 @@
|
|||
form: {},
|
||||
// 表单校验
|
||||
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,
|
||||
tel: null,
|
||||
email: null,
|
||||
createBy: null,
|
||||
updateBy: null
|
||||
};
|
||||
this.resultsList = [];
|
||||
this.resetForm("form");
|
||||
|
|
@ -326,6 +345,8 @@
|
|||
handleAddResults() {
|
||||
let obj = {};
|
||||
obj.java = "";
|
||||
obj.images = "";
|
||||
obj.file = "";
|
||||
this.resultsList.push(obj);
|
||||
},
|
||||
/** 成绩删除按钮操作 */
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.hchyun;
|
|||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
/**
|
||||
* 启动程序
|
||||
|
|
@ -10,10 +11,9 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|||
* @author hchyun
|
||||
*/
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||
public class HchYunApplication
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
//@EnableSwagger2
|
||||
public class HchYunApplication {
|
||||
public static void main(String[] args) {
|
||||
// System.setProperty("spring.devtools.restart.enabled", "false");
|
||||
SpringApplication.run(HchYunApplication.class, args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 宏驰云启动成功 ლ(´ڡ`ლ)゙ \n");
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import javax.annotation.Resource;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.util.FastByteArrayOutputStream;
|
||||
|
|
@ -24,8 +25,7 @@ import com.hchyun.common.utils.uuid.IdUtils;
|
|||
* @author hchyun
|
||||
*/
|
||||
@RestController
|
||||
public class CaptchaController
|
||||
{
|
||||
public class CaptchaController {
|
||||
@Resource(name = "captchaProducer")
|
||||
private Producer captchaProducer;
|
||||
|
||||
|
|
@ -43,8 +43,7 @@ public class CaptchaController
|
|||
* 生成验证码
|
||||
*/
|
||||
@GetMapping("/captchaImage")
|
||||
public AjaxResult getCode(HttpServletResponse response) throws IOException
|
||||
{
|
||||
public AjaxResult getCode(HttpServletResponse response) throws IOException {
|
||||
// 保存验证码信息
|
||||
String uuid = IdUtils.simpleUUID();
|
||||
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
||||
|
|
@ -53,15 +52,12 @@ public class CaptchaController
|
|||
BufferedImage image = null;
|
||||
|
||||
// 生成验证码
|
||||
if ("math".equals(captchaType))
|
||||
{
|
||||
if ("math".equals(captchaType)) {
|
||||
String capText = captchaProducerMath.createText();
|
||||
capStr = capText.substring(0, capText.lastIndexOf("@"));
|
||||
code = capText.substring(capText.lastIndexOf("@") + 1);
|
||||
image = captchaProducerMath.createImage(capStr);
|
||||
}
|
||||
else if ("char".equals(captchaType))
|
||||
{
|
||||
} else if ("char".equals(captchaType)) {
|
||||
capStr = code = captchaProducer.createText();
|
||||
image = captchaProducer.createImage(capStr);
|
||||
}
|
||||
|
|
@ -69,12 +65,9 @@ public class CaptchaController
|
|||
redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
|
||||
// 转换流信息写出
|
||||
FastByteArrayOutputStream os = new FastByteArrayOutputStream();
|
||||
try
|
||||
{
|
||||
try {
|
||||
ImageIO.write(image, "jpg" , os);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.hchyun.web.controller.common;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -23,8 +24,7 @@ import com.hchyun.framework.config.ServerConfig;
|
|||
* @author hchyun
|
||||
*/
|
||||
@RestController
|
||||
public class CommonController
|
||||
{
|
||||
public class CommonController {
|
||||
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
||||
|
||||
@Autowired
|
||||
|
|
@ -37,12 +37,9 @@ public class CommonController
|
|||
* @param delete 是否删除
|
||||
*/
|
||||
@GetMapping("common/download")
|
||||
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!FileUtils.isValidFilename(fileName))
|
||||
{
|
||||
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) {
|
||||
try {
|
||||
if (!FileUtils.isValidFilename(fileName)) {
|
||||
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 " , fileName));
|
||||
}
|
||||
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
|
||||
|
|
@ -53,13 +50,10 @@ public class CommonController
|
|||
response.setHeader("Content-Disposition" ,
|
||||
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName));
|
||||
FileUtils.writeBytes(filePath, response.getOutputStream());
|
||||
if (delete)
|
||||
{
|
||||
if (delete) {
|
||||
FileUtils.deleteFile(filePath);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
log.error("下载文件失败" , e);
|
||||
}
|
||||
}
|
||||
|
|
@ -68,10 +62,8 @@ public class CommonController
|
|||
* 通用上传请求
|
||||
*/
|
||||
@PostMapping("/common/upload")
|
||||
public AjaxResult uploadFile(MultipartFile file) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
public AjaxResult uploadFile(MultipartFile file) throws Exception {
|
||||
try {
|
||||
// 上传文件路径
|
||||
String filePath = HchYunConfig.getUploadPath();
|
||||
// 上传并返回新文件名称
|
||||
|
|
@ -81,9 +73,7 @@ public class CommonController
|
|||
ajax.put("fileName" , fileName);
|
||||
ajax.put("url" , url);
|
||||
return ajax;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -92,8 +82,7 @@ public class CommonController
|
|||
* 本地资源通用下载
|
||||
*/
|
||||
@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();
|
||||
// 数据库资源地址
|
||||
|
|
|
|||
|
|
@ -15,12 +15,10 @@ import com.hchyun.framework.web.domain.Server;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/server")
|
||||
public class ServerController extends BaseController
|
||||
{
|
||||
public class ServerController extends BaseController {
|
||||
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
|
||||
@GetMapping()
|
||||
public AjaxResult getInfo() throws Exception
|
||||
{
|
||||
public AjaxResult getInfo() throws Exception {
|
||||
Server server = new Server();
|
||||
server.copyTo();
|
||||
return AjaxResult.success(server);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.hchyun.web.controller.monitor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
|
|
@ -24,15 +25,13 @@ import com.hchyun.system.service.ISysLogininforService;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/logininfor")
|
||||
public class SysLogininforController extends BaseController
|
||||
{
|
||||
public class SysLogininforController extends BaseController {
|
||||
@Autowired
|
||||
private ISysLogininforService logininforService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysLogininfor logininfor)
|
||||
{
|
||||
public TableDataInfo list(SysLogininfor logininfor) {
|
||||
startPage();
|
||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||
return getDataTable(list);
|
||||
|
|
@ -41,8 +40,7 @@ public class SysLogininforController extends BaseController
|
|||
@Log(title = "登录日志" , businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(SysLogininfor logininfor)
|
||||
{
|
||||
public AjaxResult export(SysLogininfor logininfor) {
|
||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
||||
return util.exportExcel(list, "登录日志");
|
||||
|
|
@ -51,16 +49,14 @@ public class SysLogininforController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||
@Log(title = "登录日志" , businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{infoIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] infoIds)
|
||||
{
|
||||
public AjaxResult remove(@PathVariable Long[] infoIds) {
|
||||
return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||
@Log(title = "登录日志" , businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/clean")
|
||||
public AjaxResult clean()
|
||||
{
|
||||
public AjaxResult clean() {
|
||||
logininforService.cleanLogininfor();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.hchyun.web.controller.monitor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
|
|
@ -24,15 +25,13 @@ import com.hchyun.system.service.ISysOperLogService;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/operlog")
|
||||
public class SysOperlogController extends BaseController
|
||||
{
|
||||
public class SysOperlogController extends BaseController {
|
||||
@Autowired
|
||||
private ISysOperLogService operLogService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysOperLog operLog)
|
||||
{
|
||||
public TableDataInfo list(SysOperLog operLog) {
|
||||
startPage();
|
||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||
return getDataTable(list);
|
||||
|
|
@ -41,8 +40,7 @@ public class SysOperlogController extends BaseController
|
|||
@Log(title = "操作日志" , businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(SysOperLog operLog)
|
||||
{
|
||||
public AjaxResult export(SysOperLog operLog) {
|
||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
|
||||
return util.exportExcel(list, "操作日志");
|
||||
|
|
@ -50,16 +48,14 @@ public class SysOperlogController extends BaseController
|
|||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||
@DeleteMapping("/{operIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] operIds)
|
||||
{
|
||||
public AjaxResult remove(@PathVariable Long[] operIds) {
|
||||
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
||||
}
|
||||
|
||||
@Log(title = "操作日志" , businessType = BusinessType.CLEAN)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||
@DeleteMapping("/clean")
|
||||
public AjaxResult clean()
|
||||
{
|
||||
public AjaxResult clean() {
|
||||
operLogService.cleanOperLog();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
|
|
@ -30,8 +31,7 @@ import com.hchyun.system.service.ISysUserOnlineService;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/online")
|
||||
public class SysUserOnlineController extends BaseController
|
||||
{
|
||||
public class SysUserOnlineController extends BaseController {
|
||||
@Autowired
|
||||
private ISysUserOnlineService userOnlineService;
|
||||
|
||||
|
|
@ -40,36 +40,24 @@ public class SysUserOnlineController extends BaseController
|
|||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:online: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 + "*");
|
||||
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
|
||||
for (String key : keys)
|
||||
{
|
||||
for (String key : keys) {
|
||||
LoginUser user = redisCache.getCacheObject(key);
|
||||
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName))
|
||||
{
|
||||
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername()))
|
||||
{
|
||||
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) {
|
||||
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) {
|
||||
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
||||
}
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(ipaddr))
|
||||
{
|
||||
if (StringUtils.equals(ipaddr, user.getIpaddr()))
|
||||
{
|
||||
} else if (StringUtils.isNotEmpty(ipaddr)) {
|
||||
if (StringUtils.equals(ipaddr, user.getIpaddr())) {
|
||||
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
|
||||
}
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser()))
|
||||
{
|
||||
if (StringUtils.equals(userName, user.getUsername()))
|
||||
{
|
||||
} else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) {
|
||||
if (StringUtils.equals(userName, user.getUsername())) {
|
||||
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
userOnlineList.add(userOnlineService.loginUserToUserOnline(user));
|
||||
}
|
||||
}
|
||||
|
|
@ -84,8 +72,7 @@ public class SysUserOnlineController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
|
||||
@Log(title = "在线用户" , businessType = BusinessType.FORCE)
|
||||
@DeleteMapping("/{tokenId}")
|
||||
public AjaxResult forceLogout(@PathVariable String tokenId)
|
||||
{
|
||||
public AjaxResult forceLogout(@PathVariable String tokenId) {
|
||||
redisCache.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.hchyun.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
@ -31,8 +32,7 @@ import com.hchyun.system.service.ISysConfigService;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/config")
|
||||
public class SysConfigController extends BaseController
|
||||
{
|
||||
public class SysConfigController extends BaseController {
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
|
|
@ -41,8 +41,7 @@ public class SysConfigController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysConfig config)
|
||||
{
|
||||
public TableDataInfo list(SysConfig config) {
|
||||
startPage();
|
||||
List<SysConfig> list = configService.selectConfigList(config);
|
||||
return getDataTable(list);
|
||||
|
|
@ -51,8 +50,7 @@ public class SysConfigController extends BaseController
|
|||
@Log(title = "参数管理" , businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:config:export')")
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(SysConfig config)
|
||||
{
|
||||
public AjaxResult export(SysConfig config) {
|
||||
List<SysConfig> list = configService.selectConfigList(config);
|
||||
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
|
||||
return util.exportExcel(list, "参数数据");
|
||||
|
|
@ -63,8 +61,7 @@ public class SysConfigController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:query')")
|
||||
@GetMapping(value = "/{configId}")
|
||||
public AjaxResult getInfo(@PathVariable Long configId)
|
||||
{
|
||||
public AjaxResult getInfo(@PathVariable Long configId) {
|
||||
return AjaxResult.success(configService.selectConfigById(configId));
|
||||
}
|
||||
|
||||
|
|
@ -72,8 +69,7 @@ public class SysConfigController extends BaseController
|
|||
* 根据参数键名查询参数值
|
||||
*/
|
||||
@GetMapping(value = "/configKey/{configKey}")
|
||||
public AjaxResult getConfigKey(@PathVariable String configKey)
|
||||
{
|
||||
public AjaxResult getConfigKey(@PathVariable String configKey) {
|
||||
return AjaxResult.success(configService.selectConfigByKey(configKey));
|
||||
}
|
||||
|
||||
|
|
@ -84,10 +80,8 @@ public class SysConfigController extends BaseController
|
|||
@Log(title = "参数管理" , businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@RepeatSubmit
|
||||
public AjaxResult add(@Validated @RequestBody SysConfig config)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
||||
{
|
||||
public AjaxResult add(@Validated @RequestBody SysConfig config) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
|
||||
return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||
}
|
||||
config.setCreateBy(SecurityUtils.getUserId());
|
||||
|
|
@ -100,10 +94,8 @@ public class SysConfigController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:config:edit')")
|
||||
@Log(title = "参数管理" , businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysConfig config)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
||||
{
|
||||
public AjaxResult edit(@Validated @RequestBody SysConfig config) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
|
||||
return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||
}
|
||||
config.setUpdateBy(SecurityUtils.getUserId());
|
||||
|
|
@ -116,8 +108,7 @@ public class SysConfigController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||
@Log(title = "参数管理" , businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{configIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] configIds)
|
||||
{
|
||||
public AjaxResult remove(@PathVariable Long[] configIds) {
|
||||
return toAjax(configService.deleteConfigByIds(configIds));
|
||||
}
|
||||
|
||||
|
|
@ -127,8 +118,7 @@ public class SysConfigController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||
@Log(title = "参数管理" , businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/clearCache")
|
||||
public AjaxResult clearCache()
|
||||
{
|
||||
public AjaxResult clearCache() {
|
||||
configService.clearCache();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.hchyun.web.controller.system;
|
|||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
|
@ -31,8 +32,7 @@ import com.hchyun.system.service.ISysDeptService;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/dept")
|
||||
public class SysDeptController extends BaseController
|
||||
{
|
||||
public class SysDeptController extends BaseController {
|
||||
@Autowired
|
||||
private ISysDeptService deptService;
|
||||
|
||||
|
|
@ -41,8 +41,7 @@ public class SysDeptController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(SysDept dept)
|
||||
{
|
||||
public AjaxResult list(SysDept dept) {
|
||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||
return AjaxResult.success(depts);
|
||||
}
|
||||
|
|
@ -52,16 +51,13 @@ public class SysDeptController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
||||
@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());
|
||||
Iterator<SysDept> it = depts.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
while (it.hasNext()) {
|
||||
SysDept d = (SysDept) it.next();
|
||||
if (d.getDeptId().intValue() == deptId
|
||||
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""))
|
||||
{
|
||||
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
|
@ -73,8 +69,7 @@ public class SysDeptController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dept:query')")
|
||||
@GetMapping(value = "/{deptId}")
|
||||
public AjaxResult getInfo(@PathVariable Long deptId)
|
||||
{
|
||||
public AjaxResult getInfo(@PathVariable Long deptId) {
|
||||
return AjaxResult.success(deptService.selectDeptById(deptId));
|
||||
}
|
||||
|
||||
|
|
@ -82,8 +77,7 @@ public class SysDeptController extends BaseController
|
|||
* 获取部门下拉树列表
|
||||
*/
|
||||
@GetMapping("/treeselect")
|
||||
public AjaxResult treeselect(SysDept dept)
|
||||
{
|
||||
public AjaxResult treeselect(SysDept dept) {
|
||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||
return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
|
||||
}
|
||||
|
|
@ -92,8 +86,7 @@ public class SysDeptController extends BaseController
|
|||
* 加载对应角色部门列表树
|
||||
*/
|
||||
@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());
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("checkedKeys" , deptService.selectDeptListByRoleId(roleId));
|
||||
|
|
@ -107,10 +100,8 @@ public class SysDeptController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:dept:add')")
|
||||
@Log(title = "部门管理" , businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysDept dept)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
||||
{
|
||||
public AjaxResult add(@Validated @RequestBody SysDept dept) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
|
||||
return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||
}
|
||||
dept.setCreateBy(SecurityUtils.getUserId());
|
||||
|
|
@ -123,19 +114,13 @@ public class SysDeptController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:dept:edit')")
|
||||
@Log(title = "部门管理" , businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysDept dept)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
||||
{
|
||||
public AjaxResult edit(@Validated @RequestBody SysDept dept) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
|
||||
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||
}
|
||||
else if (dept.getParentId().equals(dept.getDeptId()))
|
||||
{
|
||||
} else if (dept.getParentId().equals(dept.getDeptId())) {
|
||||
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||
}
|
||||
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
||||
&& deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0)
|
||||
{
|
||||
} else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
||||
&& deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) {
|
||||
return AjaxResult.error("该部门包含未停用的子部门!");
|
||||
}
|
||||
dept.setUpdateBy(SecurityUtils.getUserId());
|
||||
|
|
@ -148,14 +133,11 @@ public class SysDeptController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:dept:remove')")
|
||||
@Log(title = "部门管理" , businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{deptId}")
|
||||
public AjaxResult remove(@PathVariable Long deptId)
|
||||
{
|
||||
if (deptService.hasChildByDeptId(deptId))
|
||||
{
|
||||
public AjaxResult remove(@PathVariable Long deptId) {
|
||||
if (deptService.hasChildByDeptId(deptId)) {
|
||||
return AjaxResult.error("存在下级部门,不允许删除");
|
||||
}
|
||||
if (deptService.checkDeptExistUser(deptId))
|
||||
{
|
||||
if (deptService.checkDeptExistUser(deptId)) {
|
||||
return AjaxResult.error("部门存在用户,不允许删除");
|
||||
}
|
||||
return toAjax(deptService.deleteDeptById(deptId));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.hchyun.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
@ -30,8 +31,7 @@ import com.hchyun.system.service.ISysDictTypeService;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/dict/data")
|
||||
public class SysDictDataController extends BaseController
|
||||
{
|
||||
public class SysDictDataController extends BaseController {
|
||||
@Autowired
|
||||
private ISysDictDataService dictDataService;
|
||||
|
||||
|
|
@ -40,8 +40,7 @@ public class SysDictDataController extends BaseController
|
|||
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysDictData dictData)
|
||||
{
|
||||
public TableDataInfo list(SysDictData dictData) {
|
||||
startPage();
|
||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||
return getDataTable(list);
|
||||
|
|
@ -50,8 +49,7 @@ public class SysDictDataController extends BaseController
|
|||
@Log(title = "字典数据" , businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(SysDictData dictData)
|
||||
{
|
||||
public AjaxResult export(SysDictData dictData) {
|
||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
|
||||
return util.exportExcel(list, "字典数据");
|
||||
|
|
@ -62,8 +60,7 @@ public class SysDictDataController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||
@GetMapping(value = "/{dictCode}")
|
||||
public AjaxResult getInfo(@PathVariable Long dictCode)
|
||||
{
|
||||
public AjaxResult getInfo(@PathVariable Long dictCode) {
|
||||
return AjaxResult.success(dictDataService.selectDictDataById(dictCode));
|
||||
}
|
||||
|
||||
|
|
@ -71,8 +68,7 @@ public class SysDictDataController extends BaseController
|
|||
* 根据字典类型查询字典数据信息
|
||||
*/
|
||||
@GetMapping(value = "/type/{dictType}")
|
||||
public AjaxResult dictType(@PathVariable String dictType)
|
||||
{
|
||||
public AjaxResult dictType(@PathVariable String dictType) {
|
||||
return AjaxResult.success(dictTypeService.selectDictDataByType(dictType));
|
||||
}
|
||||
|
||||
|
|
@ -82,8 +78,7 @@ public class SysDictDataController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||
@Log(title = "字典数据" , businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysDictData dict)
|
||||
{
|
||||
public AjaxResult add(@Validated @RequestBody SysDictData dict) {
|
||||
dict.setCreateBy(SecurityUtils.getUserId());
|
||||
return toAjax(dictDataService.insertDictData(dict));
|
||||
}
|
||||
|
|
@ -94,8 +89,7 @@ public class SysDictDataController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||
@Log(title = "字典数据" , businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysDictData dict)
|
||||
{
|
||||
public AjaxResult edit(@Validated @RequestBody SysDictData dict) {
|
||||
dict.setUpdateBy(SecurityUtils.getUserId());
|
||||
return toAjax(dictDataService.updateDictData(dict));
|
||||
}
|
||||
|
|
@ -106,8 +100,7 @@ public class SysDictDataController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||
@Log(title = "字典类型" , businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictCodes}")
|
||||
public AjaxResult remove(@PathVariable Long[] dictCodes)
|
||||
{
|
||||
public AjaxResult remove(@PathVariable Long[] dictCodes) {
|
||||
return toAjax(dictDataService.deleteDictDataByIds(dictCodes));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.hchyun.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
@ -30,15 +31,13 @@ import com.hchyun.system.service.ISysDictTypeService;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/dict/type")
|
||||
public class SysDictTypeController extends BaseController
|
||||
{
|
||||
public class SysDictTypeController extends BaseController {
|
||||
@Autowired
|
||||
private ISysDictTypeService dictTypeService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysDictType dictType)
|
||||
{
|
||||
public TableDataInfo list(SysDictType dictType) {
|
||||
startPage();
|
||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||
return getDataTable(list);
|
||||
|
|
@ -47,8 +46,7 @@ public class SysDictTypeController extends BaseController
|
|||
@Log(title = "字典类型" , businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(SysDictType dictType)
|
||||
{
|
||||
public AjaxResult export(SysDictType dictType) {
|
||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
|
||||
return util.exportExcel(list, "字典类型");
|
||||
|
|
@ -59,8 +57,7 @@ public class SysDictTypeController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||
@GetMapping(value = "/{dictId}")
|
||||
public AjaxResult getInfo(@PathVariable Long dictId)
|
||||
{
|
||||
public AjaxResult getInfo(@PathVariable Long dictId) {
|
||||
return AjaxResult.success(dictTypeService.selectDictTypeById(dictId));
|
||||
}
|
||||
|
||||
|
|
@ -70,10 +67,8 @@ public class SysDictTypeController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||
@Log(title = "字典类型" , businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysDictType dict)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
||||
{
|
||||
public AjaxResult add(@Validated @RequestBody SysDictType dict) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
||||
return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
dict.setCreateBy(SecurityUtils.getUserId());
|
||||
|
|
@ -86,10 +81,8 @@ public class SysDictTypeController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||
@Log(title = "字典类型" , businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysDictType dict)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
||||
{
|
||||
public AjaxResult edit(@Validated @RequestBody SysDictType dict) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
||||
return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
dict.setUpdateBy(SecurityUtils.getUserId());
|
||||
|
|
@ -102,8 +95,7 @@ public class SysDictTypeController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||
@Log(title = "字典类型" , businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] dictIds)
|
||||
{
|
||||
public AjaxResult remove(@PathVariable Long[] dictIds) {
|
||||
return toAjax(dictTypeService.deleteDictTypeByIds(dictIds));
|
||||
}
|
||||
|
||||
|
|
@ -113,8 +105,7 @@ public class SysDictTypeController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||
@Log(title = "字典类型" , businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/clearCache")
|
||||
public AjaxResult clearCache()
|
||||
{
|
||||
public AjaxResult clearCache() {
|
||||
dictTypeService.clearCache();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
|
@ -123,8 +114,7 @@ public class SysDictTypeController extends BaseController
|
|||
* 获取字典选择框列表
|
||||
*/
|
||||
@GetMapping("/optionselect")
|
||||
public AjaxResult optionselect()
|
||||
{
|
||||
public AjaxResult optionselect() {
|
||||
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
||||
return AjaxResult.success(dictTypes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.hchyun.web.controller.system;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
|
@ -25,8 +26,7 @@ import com.hchyun.system.service.ISysMenuService;
|
|||
* @author hchyun
|
||||
*/
|
||||
@RestController
|
||||
public class SysLoginController
|
||||
{
|
||||
public class SysLoginController {
|
||||
@Autowired
|
||||
private SysLoginService loginService;
|
||||
|
||||
|
|
@ -46,8 +46,7 @@ public class SysLoginController
|
|||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public AjaxResult login(@RequestBody LoginBody loginBody)
|
||||
{
|
||||
public AjaxResult login(@RequestBody LoginBody loginBody) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
// 生成令牌
|
||||
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
||||
|
|
@ -62,8 +61,7 @@ public class SysLoginController
|
|||
* @return 用户信息
|
||||
*/
|
||||
@GetMapping("getInfo")
|
||||
public AjaxResult getInfo()
|
||||
{
|
||||
public AjaxResult getInfo() {
|
||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
SysUser user = loginUser.getUser();
|
||||
// 角色集合
|
||||
|
|
@ -83,8 +81,7 @@ public class SysLoginController
|
|||
* @return 路由信息
|
||||
*/
|
||||
@GetMapping("getRouters")
|
||||
public AjaxResult getRouters()
|
||||
{
|
||||
public AjaxResult getRouters() {
|
||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
// 用户信息
|
||||
SysUser user = loginUser.getUser();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.hchyun.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
@ -33,8 +34,7 @@ import com.hchyun.system.service.ISysMenuService;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/menu")
|
||||
public class SysMenuController extends BaseController
|
||||
{
|
||||
public class SysMenuController extends BaseController {
|
||||
@Autowired
|
||||
private ISysMenuService menuService;
|
||||
|
||||
|
|
@ -46,8 +46,7 @@ public class SysMenuController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:menu:list')")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(SysMenu menu)
|
||||
{
|
||||
public AjaxResult list(SysMenu menu) {
|
||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
Long userId = loginUser.getUser().getUserId();
|
||||
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
||||
|
|
@ -59,8 +58,7 @@ public class SysMenuController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:menu:query')")
|
||||
@GetMapping(value = "/{menuId}")
|
||||
public AjaxResult getInfo(@PathVariable Long menuId)
|
||||
{
|
||||
public AjaxResult getInfo(@PathVariable Long menuId) {
|
||||
return AjaxResult.success(menuService.selectMenuById(menuId));
|
||||
}
|
||||
|
||||
|
|
@ -68,8 +66,7 @@ public class SysMenuController extends BaseController
|
|||
* 获取菜单下拉树列表
|
||||
*/
|
||||
@GetMapping("/treeselect")
|
||||
public AjaxResult treeselect(SysMenu menu)
|
||||
{
|
||||
public AjaxResult treeselect(SysMenu menu) {
|
||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
Long userId = loginUser.getUser().getUserId();
|
||||
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
||||
|
|
@ -80,8 +77,7 @@ public class SysMenuController extends BaseController
|
|||
* 加载对应角色菜单列表树
|
||||
*/
|
||||
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
||||
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
|
||||
{
|
||||
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
|
||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
List<SysMenu> menus = menuService.selectMenuList(loginUser.getUser().getUserId());
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
|
|
@ -96,15 +92,11 @@ public class SysMenuController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:menu:add')")
|
||||
@Log(title = "菜单管理" , businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysMenu menu)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
|
||||
{
|
||||
public AjaxResult add(@Validated @RequestBody SysMenu menu) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
||||
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||
}
|
||||
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
|
||||
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS))
|
||||
{
|
||||
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
|
||||
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) {
|
||||
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||
}
|
||||
menu.setCreateBy(SecurityUtils.getUserId());
|
||||
|
|
@ -117,19 +109,13 @@ public class SysMenuController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:menu:edit')")
|
||||
@Log(title = "菜单管理" , businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysMenu menu)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
|
||||
{
|
||||
public AjaxResult edit(@Validated @RequestBody SysMenu menu) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||
}
|
||||
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
|
||||
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS))
|
||||
{
|
||||
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
|
||||
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) {
|
||||
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() + "'失败,上级菜单不能选择自己");
|
||||
}
|
||||
menu.setUpdateBy(SecurityUtils.getUserId());
|
||||
|
|
@ -142,14 +128,11 @@ public class SysMenuController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:menu:remove')")
|
||||
@Log(title = "菜单管理" , businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{menuId}")
|
||||
public AjaxResult remove(@PathVariable("menuId") Long menuId)
|
||||
{
|
||||
if (menuService.hasChildByMenuId(menuId))
|
||||
{
|
||||
public AjaxResult remove(@PathVariable("menuId") Long menuId) {
|
||||
if (menuService.hasChildByMenuId(menuId)) {
|
||||
return AjaxResult.error("存在子菜单,不允许删除");
|
||||
}
|
||||
if (menuService.checkMenuExistRole(menuId))
|
||||
{
|
||||
if (menuService.checkMenuExistRole(menuId)) {
|
||||
return AjaxResult.error("菜单已分配,不允许删除");
|
||||
}
|
||||
return toAjax(menuService.deleteMenuById(menuId));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.hchyun.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
@ -28,8 +29,7 @@ import com.hchyun.system.service.ISysNoticeService;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/notice")
|
||||
public class SysNoticeController extends BaseController
|
||||
{
|
||||
public class SysNoticeController extends BaseController {
|
||||
@Autowired
|
||||
private ISysNoticeService noticeService;
|
||||
|
||||
|
|
@ -38,8 +38,7 @@ public class SysNoticeController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysNotice notice)
|
||||
{
|
||||
public TableDataInfo list(SysNotice notice) {
|
||||
startPage();
|
||||
List<SysNotice> list = noticeService.selectNoticeList(notice);
|
||||
return getDataTable(list);
|
||||
|
|
@ -50,8 +49,7 @@ public class SysNoticeController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:query')")
|
||||
@GetMapping(value = "/{noticeId}")
|
||||
public AjaxResult getInfo(@PathVariable Long noticeId)
|
||||
{
|
||||
public AjaxResult getInfo(@PathVariable Long noticeId) {
|
||||
return AjaxResult.success(noticeService.selectNoticeById(noticeId));
|
||||
}
|
||||
|
||||
|
|
@ -61,8 +59,7 @@ public class SysNoticeController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:notice:add')")
|
||||
@Log(title = "通知公告" , businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysNotice notice)
|
||||
{
|
||||
public AjaxResult add(@Validated @RequestBody SysNotice notice) {
|
||||
notice.setCreateBy(SecurityUtils.getUserId());
|
||||
return toAjax(noticeService.insertNotice(notice));
|
||||
}
|
||||
|
|
@ -73,8 +70,7 @@ public class SysNoticeController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:notice:edit')")
|
||||
@Log(title = "通知公告" , businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysNotice notice)
|
||||
{
|
||||
public AjaxResult edit(@Validated @RequestBody SysNotice notice) {
|
||||
notice.setUpdateBy(SecurityUtils.getUserId());
|
||||
return toAjax(noticeService.updateNotice(notice));
|
||||
}
|
||||
|
|
@ -85,8 +81,7 @@ public class SysNoticeController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:notice:remove')")
|
||||
@Log(title = "通知公告" , businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{noticeIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] noticeIds)
|
||||
{
|
||||
public AjaxResult remove(@PathVariable Long[] noticeIds) {
|
||||
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.hchyun.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
@ -30,8 +31,7 @@ import com.hchyun.system.service.ISysPostService;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/post")
|
||||
public class SysPostController extends BaseController
|
||||
{
|
||||
public class SysPostController extends BaseController {
|
||||
@Autowired
|
||||
private ISysPostService postService;
|
||||
|
||||
|
|
@ -40,8 +40,7 @@ public class SysPostController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysPost post)
|
||||
{
|
||||
public TableDataInfo list(SysPost post) {
|
||||
startPage();
|
||||
List<SysPost> list = postService.selectPostList(post);
|
||||
return getDataTable(list);
|
||||
|
|
@ -50,8 +49,7 @@ public class SysPostController extends BaseController
|
|||
@Log(title = "岗位管理" , businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:post:export')")
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(SysPost post)
|
||||
{
|
||||
public AjaxResult export(SysPost post) {
|
||||
List<SysPost> list = postService.selectPostList(post);
|
||||
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
||||
return util.exportExcel(list, "岗位数据");
|
||||
|
|
@ -62,8 +60,7 @@ public class SysPostController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:query')")
|
||||
@GetMapping(value = "/{postId}")
|
||||
public AjaxResult getInfo(@PathVariable Long postId)
|
||||
{
|
||||
public AjaxResult getInfo(@PathVariable Long postId) {
|
||||
return AjaxResult.success(postService.selectPostById(postId));
|
||||
}
|
||||
|
||||
|
|
@ -73,14 +70,10 @@ public class SysPostController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:post:add')")
|
||||
@Log(title = "岗位管理" , businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysPost post)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
||||
{
|
||||
public AjaxResult add(@Validated @RequestBody SysPost post) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
|
||||
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() + "'失败,岗位编码已存在");
|
||||
}
|
||||
post.setCreateBy(SecurityUtils.getUserId());
|
||||
|
|
@ -93,14 +86,10 @@ public class SysPostController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:post:edit')")
|
||||
@Log(title = "岗位管理" , businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysPost post)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
||||
{
|
||||
public AjaxResult edit(@Validated @RequestBody SysPost post) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
|
||||
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() + "'失败,岗位编码已存在");
|
||||
}
|
||||
post.setUpdateBy(SecurityUtils.getUserId());
|
||||
|
|
@ -113,8 +102,7 @@ public class SysPostController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:post:remove')")
|
||||
@Log(title = "岗位管理" , businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{postIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] postIds)
|
||||
{
|
||||
public AjaxResult remove(@PathVariable Long[] postIds) {
|
||||
return toAjax(postService.deletePostByIds(postIds));
|
||||
}
|
||||
|
||||
|
|
@ -122,8 +110,7 @@ public class SysPostController extends BaseController
|
|||
* 获取岗位选择框列表
|
||||
*/
|
||||
@GetMapping("/optionselect")
|
||||
public AjaxResult optionselect()
|
||||
{
|
||||
public AjaxResult optionselect() {
|
||||
List<SysPost> posts = postService.selectPostAll();
|
||||
return AjaxResult.success(posts);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.hchyun.web.controller.system;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
|
@ -30,8 +31,7 @@ import com.hchyun.system.service.ISysUserService;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/user/profile")
|
||||
public class SysProfileController extends BaseController
|
||||
{
|
||||
public class SysProfileController extends BaseController {
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
|
|
@ -42,8 +42,7 @@ public class SysProfileController extends BaseController
|
|||
* 个人信息
|
||||
*/
|
||||
@GetMapping
|
||||
public AjaxResult profile()
|
||||
{
|
||||
public AjaxResult profile() {
|
||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
SysUser user = loginUser.getUser();
|
||||
AjaxResult ajax = AjaxResult.success(user);
|
||||
|
|
@ -57,10 +56,8 @@ public class SysProfileController extends BaseController
|
|||
*/
|
||||
@Log(title = "个人信息" , businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult updateProfile(@RequestBody SysUser user)
|
||||
{
|
||||
if (userService.updateUserProfile(user) > 0)
|
||||
{
|
||||
public AjaxResult updateProfile(@RequestBody SysUser user) {
|
||||
if (userService.updateUserProfile(user) > 0) {
|
||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
// 更新缓存用户信息
|
||||
loginUser.getUser().setNickName(user.getNickName());
|
||||
|
|
@ -78,21 +75,17 @@ public class SysProfileController extends BaseController
|
|||
*/
|
||||
@Log(title = "个人信息" , businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/updatePwd")
|
||||
public AjaxResult updatePwd(String oldPassword, String newPassword)
|
||||
{
|
||||
public AjaxResult updatePwd(String oldPassword, String newPassword) {
|
||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
String userName = loginUser.getUsername();
|
||||
String password = loginUser.getPassword();
|
||||
if (!SecurityUtils.matchesPassword(oldPassword, password))
|
||||
{
|
||||
if (!SecurityUtils.matchesPassword(oldPassword, password)) {
|
||||
return AjaxResult.error("修改密码失败,旧密码错误");
|
||||
}
|
||||
if (SecurityUtils.matchesPassword(newPassword, password))
|
||||
{
|
||||
if (SecurityUtils.matchesPassword(newPassword, password)) {
|
||||
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));
|
||||
tokenService.setLoginUser(loginUser);
|
||||
|
|
@ -106,14 +99,11 @@ public class SysProfileController extends BaseController
|
|||
*/
|
||||
@Log(title = "用户头像" , businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/avatar")
|
||||
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException
|
||||
{
|
||||
if (!file.isEmpty())
|
||||
{
|
||||
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException {
|
||||
if (!file.isEmpty()) {
|
||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
String avatar = FileUploadUtils.upload(HchYunConfig.getAvatarPath(), file);
|
||||
if (userService.updateUserAvatar(loginUser.getUsername(), avatar))
|
||||
{
|
||||
if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("imgUrl" , avatar);
|
||||
// 更新缓存用户头像
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.hchyun.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
@ -36,8 +37,7 @@ import com.hchyun.system.service.ISysUserService;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/role")
|
||||
public class SysRoleController extends BaseController
|
||||
{
|
||||
public class SysRoleController extends BaseController {
|
||||
@Autowired
|
||||
private ISysRoleService roleService;
|
||||
|
||||
|
|
@ -52,8 +52,7 @@ public class SysRoleController extends BaseController
|
|||
|
||||
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysRole role)
|
||||
{
|
||||
public TableDataInfo list(SysRole role) {
|
||||
startPage();
|
||||
List<SysRole> list = roleService.selectRoleList(role);
|
||||
return getDataTable(list);
|
||||
|
|
@ -62,8 +61,7 @@ public class SysRoleController extends BaseController
|
|||
@Log(title = "角色管理" , businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:role:export')")
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(SysRole role)
|
||||
{
|
||||
public AjaxResult export(SysRole role) {
|
||||
List<SysRole> list = roleService.selectRoleList(role);
|
||||
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
||||
return util.exportExcel(list, "角色数据");
|
||||
|
|
@ -74,8 +72,7 @@ public class SysRoleController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||
@GetMapping(value = "/{roleId}")
|
||||
public AjaxResult getInfo(@PathVariable Long roleId)
|
||||
{
|
||||
public AjaxResult getInfo(@PathVariable Long roleId) {
|
||||
return AjaxResult.success(roleService.selectRoleById(roleId));
|
||||
}
|
||||
|
||||
|
|
@ -85,14 +82,10 @@ public class SysRoleController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:role:add')")
|
||||
@Log(title = "角色管理" , businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysRole role)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
||||
{
|
||||
public AjaxResult add(@Validated @RequestBody SysRole role) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
|
||||
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() + "'失败,角色权限已存在");
|
||||
}
|
||||
role.setCreateBy(SecurityUtils.getUserId());
|
||||
|
|
@ -106,25 +99,19 @@ public class SysRoleController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理" , businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysRole role)
|
||||
{
|
||||
public AjaxResult edit(@Validated @RequestBody SysRole 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() + "'失败,角色名称已存在");
|
||||
}
|
||||
else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
||||
{
|
||||
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
|
||||
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||
}
|
||||
role.setUpdateBy(SecurityUtils.getUserId());
|
||||
|
||||
if (roleService.updateRole(role) > 0)
|
||||
{
|
||||
if (roleService.updateRole(role) > 0) {
|
||||
// 更新缓存用户权限
|
||||
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.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
|
||||
tokenService.setLoginUser(loginUser);
|
||||
|
|
@ -140,8 +127,7 @@ public class SysRoleController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理" , businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/dataScope")
|
||||
public AjaxResult dataScope(@RequestBody SysRole role)
|
||||
{
|
||||
public AjaxResult dataScope(@RequestBody SysRole role) {
|
||||
roleService.checkRoleAllowed(role);
|
||||
return toAjax(roleService.authDataScope(role));
|
||||
}
|
||||
|
|
@ -152,8 +138,7 @@ public class SysRoleController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理" , businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public AjaxResult changeStatus(@RequestBody SysRole role)
|
||||
{
|
||||
public AjaxResult changeStatus(@RequestBody SysRole role) {
|
||||
roleService.checkRoleAllowed(role);
|
||||
role.setUpdateBy(SecurityUtils.getUserId());
|
||||
return toAjax(roleService.updateRoleStatus(role));
|
||||
|
|
@ -165,8 +150,7 @@ public class SysRoleController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:role:remove')")
|
||||
@Log(title = "角色管理" , businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{roleIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] roleIds)
|
||||
{
|
||||
public AjaxResult remove(@PathVariable Long[] roleIds) {
|
||||
return toAjax(roleService.deleteRoleByIds(roleIds));
|
||||
}
|
||||
|
||||
|
|
@ -175,8 +159,7 @@ public class SysRoleController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||
@GetMapping("/optionselect")
|
||||
public AjaxResult optionselect()
|
||||
{
|
||||
public AjaxResult optionselect() {
|
||||
return AjaxResult.success(roleService.selectRoleAll());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.hchyun.web.controller.system;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
@ -39,8 +40,7 @@ import com.hchyun.system.service.ISysUserService;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/user")
|
||||
public class SysUserController extends BaseController
|
||||
{
|
||||
public class SysUserController extends BaseController {
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
|
|
@ -58,8 +58,7 @@ public class SysUserController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysUser user)
|
||||
{
|
||||
public TableDataInfo list(SysUser user) {
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
return getDataTable(list);
|
||||
|
|
@ -68,8 +67,7 @@ public class SysUserController extends BaseController
|
|||
@Log(title = "用户管理" , businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:user:export')")
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(SysUser user)
|
||||
{
|
||||
public AjaxResult export(SysUser user) {
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
return util.exportExcel(list, "用户数据");
|
||||
|
|
@ -78,8 +76,7 @@ public class SysUserController extends BaseController
|
|||
@Log(title = "用户管理" , businessType = BusinessType.IMPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:user:import')")
|
||||
@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);
|
||||
List<SysUser> userList = util.importExcel(file.getInputStream());
|
||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
|
|
@ -89,8 +86,7 @@ public class SysUserController extends BaseController
|
|||
}
|
||||
|
||||
@GetMapping("/importTemplate")
|
||||
public AjaxResult importTemplate()
|
||||
{
|
||||
public AjaxResult importTemplate() {
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
return util.importTemplateExcel("用户数据");
|
||||
}
|
||||
|
|
@ -100,14 +96,12 @@ public class SysUserController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||
@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();
|
||||
List<SysRole> roles = roleService.selectRoleAll();
|
||||
ajax.put("roles" , SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||
ajax.put("posts" , postService.selectPostAll());
|
||||
if (StringUtils.isNotNull(userId))
|
||||
{
|
||||
if (StringUtils.isNotNull(userId)) {
|
||||
ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
|
||||
ajax.put("postIds" , postService.selectPostListByUserId(userId));
|
||||
ajax.put("roleIds" , roleService.selectRoleListByUserId(userId));
|
||||
|
|
@ -121,18 +115,12 @@ public class SysUserController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:user:add')")
|
||||
@Log(title = "用户管理" , businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysUser user)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName())))
|
||||
{
|
||||
public AjaxResult add(@Validated @RequestBody SysUser user) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(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() + "'失败,手机号码已存在");
|
||||
}
|
||||
else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||
{
|
||||
} else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
user.setCreateBy(SecurityUtils.getUserId());
|
||||
|
|
@ -146,15 +134,11 @@ public class SysUserController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
@Log(title = "用户管理" , businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
||||
{
|
||||
public AjaxResult edit(@Validated @RequestBody SysUser 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() + "'失败,手机号码已存在");
|
||||
}
|
||||
else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||
{
|
||||
} else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
user.setUpdateBy(SecurityUtils.getUserId());
|
||||
|
|
@ -167,8 +151,7 @@ public class SysUserController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:user:remove')")
|
||||
@Log(title = "用户管理" , businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{userIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] userIds)
|
||||
{
|
||||
public AjaxResult remove(@PathVariable Long[] userIds) {
|
||||
return toAjax(userService.deleteUserByIds(userIds));
|
||||
}
|
||||
|
||||
|
|
@ -178,8 +161,7 @@ public class SysUserController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
|
||||
@Log(title = "用户管理" , businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/resetPwd")
|
||||
public AjaxResult resetPwd(@RequestBody SysUser user)
|
||||
{
|
||||
public AjaxResult resetPwd(@RequestBody SysUser user) {
|
||||
userService.checkUserAllowed(user);
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
user.setUpdateBy(SecurityUtils.getUserId());
|
||||
|
|
@ -192,8 +174,7 @@ public class SysUserController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
@Log(title = "用户管理" , businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public AjaxResult changeStatus(@RequestBody SysUser user)
|
||||
{
|
||||
public AjaxResult changeStatus(@RequestBody SysUser user) {
|
||||
userService.checkUserAllowed(user);
|
||||
user.setUpdateBy(SecurityUtils.getUserId());
|
||||
return toAjax(userService.updateUserStatus(user));
|
||||
|
|
|
|||
|
|
@ -13,12 +13,10 @@ import com.hchyun.common.core.controller.BaseController;
|
|||
*/
|
||||
@Controller
|
||||
@RequestMapping("/tool/swagger")
|
||||
public class SwaggerController extends BaseController
|
||||
{
|
||||
public class SwaggerController extends BaseController {
|
||||
@PreAuthorize("@ss.hasPermi('tool:swagger:view')")
|
||||
@GetMapping()
|
||||
public String index()
|
||||
{
|
||||
public String index() {
|
||||
return redirect("/swagger-ui.html");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
|
@ -28,9 +29,9 @@ import io.swagger.annotations.ApiOperation;
|
|||
@Api("用户信息管理")
|
||||
@RestController
|
||||
@RequestMapping("/test/user")
|
||||
public class TestController extends BaseController
|
||||
{
|
||||
public class TestController extends BaseController {
|
||||
private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
|
||||
|
||||
{
|
||||
users.put(1, new UserEntity(1, "admin" , "admin123" , "15888888888"));
|
||||
users.put(2, new UserEntity(2, "ry" , "admin123" , "15666666666"));
|
||||
|
|
@ -38,8 +39,7 @@ public class TestController extends BaseController
|
|||
|
||||
@ApiOperation("获取用户列表")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult userList()
|
||||
{
|
||||
public AjaxResult userList() {
|
||||
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
|
||||
return AjaxResult.success(userList);
|
||||
}
|
||||
|
|
@ -47,14 +47,10 @@ public class TestController extends BaseController
|
|||
@ApiOperation("获取用户详细")
|
||||
@ApiImplicitParam(name = "userId" , value = "用户ID" , required = true, dataType = "int" , paramType = "path")
|
||||
@GetMapping("/{userId}")
|
||||
public AjaxResult getUser(@PathVariable Integer userId)
|
||||
{
|
||||
if (!users.isEmpty() && users.containsKey(userId))
|
||||
{
|
||||
public AjaxResult getUser(@PathVariable Integer userId) {
|
||||
if (!users.isEmpty() && users.containsKey(userId)) {
|
||||
return AjaxResult.success(users.get(userId));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return AjaxResult.error("用户不存在");
|
||||
}
|
||||
}
|
||||
|
|
@ -62,10 +58,8 @@ public class TestController extends BaseController
|
|||
@ApiOperation("新增用户")
|
||||
@ApiImplicitParam(name = "userEntity" , value = "新增用户信息" , dataType = "UserEntity")
|
||||
@PostMapping("/save")
|
||||
public AjaxResult save(UserEntity user)
|
||||
{
|
||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
||||
{
|
||||
public AjaxResult save(UserEntity user) {
|
||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
|
||||
return AjaxResult.error("用户ID不能为空");
|
||||
}
|
||||
return AjaxResult.success(users.put(user.getUserId(), user));
|
||||
|
|
@ -74,14 +68,11 @@ public class TestController extends BaseController
|
|||
@ApiOperation("更新用户")
|
||||
@ApiImplicitParam(name = "userEntity" , value = "新增用户信息" , dataType = "UserEntity")
|
||||
@PutMapping("/update")
|
||||
public AjaxResult update(UserEntity user)
|
||||
{
|
||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
||||
{
|
||||
public AjaxResult update(UserEntity user) {
|
||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
|
||||
return AjaxResult.error("用户ID不能为空");
|
||||
}
|
||||
if (users.isEmpty() || !users.containsKey(user.getUserId()))
|
||||
{
|
||||
if (users.isEmpty() || !users.containsKey(user.getUserId())) {
|
||||
return AjaxResult.error("用户不存在");
|
||||
}
|
||||
users.remove(user.getUserId());
|
||||
|
|
@ -91,23 +82,18 @@ public class TestController extends BaseController
|
|||
@ApiOperation("删除用户信息")
|
||||
@ApiImplicitParam(name = "userId" , value = "用户ID" , required = true, dataType = "int" , paramType = "path")
|
||||
@DeleteMapping("/{userId}")
|
||||
public AjaxResult delete(@PathVariable Integer userId)
|
||||
{
|
||||
if (!users.isEmpty() && users.containsKey(userId))
|
||||
{
|
||||
public AjaxResult delete(@PathVariable Integer userId) {
|
||||
if (!users.isEmpty() && users.containsKey(userId)) {
|
||||
users.remove(userId);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return AjaxResult.error("用户不存在");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ApiModel("用户实体")
|
||||
class UserEntity
|
||||
{
|
||||
class UserEntity {
|
||||
@ApiModelProperty("用户ID")
|
||||
private Integer userId;
|
||||
|
||||
|
|
@ -120,56 +106,46 @@ class UserEntity
|
|||
@ApiModelProperty("用户手机")
|
||||
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.username = username;
|
||||
this.password = password;
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public Integer getUserId()
|
||||
{
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer userId)
|
||||
{
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUsername()
|
||||
{
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username)
|
||||
{
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword()
|
||||
{
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password)
|
||||
{
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getMobile()
|
||||
{
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile)
|
||||
{
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,10 +56,11 @@ public class SwaggerConfig
|
|||
// 设置哪些接口暴露给Swagger展示
|
||||
.select()
|
||||
// 扫描所有有注解的api,用这种方式更灵活
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||
// .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||
// 扫描指定包中的swagger注解
|
||||
// .apis(RequestHandlerSelectors.basePackage("com.hchyun.project.tool.swagger"))
|
||||
// 扫描所有 .apis(RequestHandlerSelectors.any())
|
||||
// 扫描所有
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
/* 设置安全模式,swagger可以设置访问token */
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ hchyun:
|
|||
# 实例演示开关
|
||||
demoEnabled: true
|
||||
# 文件路径 示例( Windows配置D:/hchyun/uploadPath,Linux配置 /home/hchyun/uploadPath)
|
||||
profile: /home/hchyun/uploadPath
|
||||
profile: F:/hchyun/uploadPath
|
||||
# 获取ip地址开关
|
||||
addressEnabled: false
|
||||
# 验证码类型 math 数组计算 char 字符验证
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.hchyun.common.core.controller;
|
|||
import java.beans.PropertyEditorSupport;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
|
|
@ -23,22 +24,18 @@ import com.hchyun.common.utils.sql.SqlUtil;
|
|||
*
|
||||
* @author hchyun
|
||||
*/
|
||||
public class BaseController
|
||||
{
|
||||
public class BaseController {
|
||||
protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
|
||||
|
||||
/**
|
||||
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
||||
*/
|
||||
@InitBinder
|
||||
public void initBinder(WebDataBinder binder)
|
||||
{
|
||||
public void initBinder(WebDataBinder binder) {
|
||||
// Date 类型转换
|
||||
binder.registerCustomEditor(Date.class, new PropertyEditorSupport()
|
||||
{
|
||||
binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text)
|
||||
{
|
||||
public void setAsText(String text) {
|
||||
setValue(DateUtils.parseDate(text));
|
||||
}
|
||||
});
|
||||
|
|
@ -47,13 +44,11 @@ public class BaseController
|
|||
/**
|
||||
* 设置请求分页数据
|
||||
*/
|
||||
protected void startPage()
|
||||
{
|
||||
protected void startPage() {
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
Integer pageNum = pageDomain.getPageNum();
|
||||
Integer pageSize = pageDomain.getPageSize();
|
||||
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
|
||||
{
|
||||
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
|
||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||
PageHelper.startPage(pageNum, pageSize, orderBy);
|
||||
}
|
||||
|
|
@ -63,8 +58,7 @@ public class BaseController
|
|||
* 响应请求分页数据
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
protected TableDataInfo getDataTable(List<?> list)
|
||||
{
|
||||
protected TableDataInfo getDataTable(List<?> list) {
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
rspData.setMsg("查询成功");
|
||||
|
|
@ -79,16 +73,15 @@ public class BaseController
|
|||
* @param rows 影响行数
|
||||
* @return 操作结果
|
||||
*/
|
||||
protected AjaxResult toAjax(int rows)
|
||||
{
|
||||
protected AjaxResult toAjax(int rows) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,14 +19,12 @@ import com.hchyun.framework.interceptor.RepeatSubmitInterceptor;
|
|||
* @author hchyun
|
||||
*/
|
||||
@Configuration
|
||||
public class ResourcesConfig implements WebMvcConfigurer
|
||||
{
|
||||
public class ResourcesConfig implements WebMvcConfigurer {
|
||||
@Autowired
|
||||
private RepeatSubmitInterceptor repeatSubmitInterceptor;
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry)
|
||||
{
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
/** 本地文件上传路径 */
|
||||
registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + HchYunConfig.getProfile() + "/");
|
||||
|
||||
|
|
@ -39,8 +37,7 @@ public class ResourcesConfig implements WebMvcConfigurer
|
|||
* 自定义拦截规则
|
||||
*/
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry)
|
||||
{
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**");
|
||||
}
|
||||
|
||||
|
|
@ -48,8 +45,7 @@ public class ResourcesConfig implements WebMvcConfigurer
|
|||
* 跨域配置
|
||||
*/
|
||||
@Bean
|
||||
public CorsFilter corsFilter()
|
||||
{
|
||||
public CorsFilter corsFilter() {
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.setAllowCredentials(true);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class ${ClassName}ServiceImpl implements ${ClassName}Service {
|
|||
public ServerResult<${ClassName}> select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField}) {
|
||||
try {
|
||||
${ClassName} ${className} = ${className}Dao.select${ClassName}ById(${pkColumn.javaField});
|
||||
if (stu != null){
|
||||
if (${className} != null){
|
||||
return new ServerResult<${ClassName}>(true,${className});
|
||||
}else {
|
||||
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
|
||||
*
|
||||
* @author hchyun
|
||||
* @date 2021-01-22
|
||||
* @date 2021-01-23
|
||||
*/
|
||||
@RestController
|
||||
@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接口
|
||||
*
|
||||
* @author hchyun
|
||||
* @date 2021-01-22
|
||||
* @date 2021-01-23
|
||||
*/
|
||||
public interface StuDao
|
||||
{
|
||||
|
|
@ -66,7 +66,7 @@ public interface StuDao
|
|||
* @param customerIds 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteResultsByIds(Long[] ids);
|
||||
int deleteResultsBySIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 批量新增成绩
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
* 成绩对象 sys_results
|
||||
*
|
||||
* @author hchyun
|
||||
* @date 2021-01-22
|
||||
* @date 2021-01-23
|
||||
*/
|
||||
public class Results extends BaseEntity
|
||||
{
|
||||
|
|
@ -26,6 +26,14 @@ public class Results extends BaseEntity
|
|||
@Excel(name = "java成绩")
|
||||
private Long java;
|
||||
|
||||
/** 图片路径 */
|
||||
@Excel(name = "图片路径")
|
||||
private String images;
|
||||
|
||||
/** 文件路径 */
|
||||
@Excel(name = "文件路径")
|
||||
private String file;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
|
|
@ -35,15 +43,15 @@ public class Results extends BaseEntity
|
|||
{
|
||||
return id;
|
||||
}
|
||||
public void setSId(Long sId)
|
||||
{
|
||||
|
||||
public Long getsId() {
|
||||
return sId;
|
||||
}
|
||||
|
||||
public void setsId(Long sId) {
|
||||
this.sId = sId;
|
||||
}
|
||||
|
||||
public Long getSId()
|
||||
{
|
||||
return sId;
|
||||
}
|
||||
public void setJava(Long java)
|
||||
{
|
||||
this.java = java;
|
||||
|
|
@ -53,13 +61,33 @@ public class Results extends BaseEntity
|
|||
{
|
||||
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
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("sId", getSId())
|
||||
.append("sId", getsId())
|
||||
.append("java", getJava())
|
||||
.append("images", getImages())
|
||||
.append("file", getFile())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
* 学生对象 sys_stu
|
||||
*
|
||||
* @author hchyun
|
||||
* @date 2021-01-22
|
||||
* @date 2021-01-23
|
||||
*/
|
||||
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接口
|
||||
*
|
||||
* @author hchyun
|
||||
* @date 2021-01-22
|
||||
* @date 2021-01-23
|
||||
*/
|
||||
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.utils.DateUtils;
|
||||
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 org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import com.hchyun.common.utils.StringUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -23,7 +24,7 @@ import com.hchyun.test.service.StuService;
|
|||
* 学生Service业务层处理
|
||||
*
|
||||
* @author hchyun
|
||||
* @date 2021-01-22
|
||||
* @date 2021-01-23
|
||||
*/
|
||||
@Service
|
||||
public class StuServiceImpl implements StuService {
|
||||
|
|
@ -86,10 +87,12 @@ public class StuServiceImpl implements StuService {
|
|||
try {
|
||||
stu.setCreateTime(DateUtils.getNowDate());
|
||||
stu.setCreateBy(SecurityUtils.getUserId());
|
||||
int rows = stuDao.insertStu(stu);
|
||||
insertResults(stu);
|
||||
if (rows > 0) {
|
||||
return new ServerResult<Integer>(true, rows);
|
||||
int renewal = stuDao.insertStu(stu);
|
||||
if (insertResults(stu)){
|
||||
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||
}
|
||||
if (renewal >0){
|
||||
return new ServerResult<Integer>(true,renewal);
|
||||
}else {
|
||||
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
|
||||
}
|
||||
|
|
@ -137,8 +140,8 @@ public class StuServiceImpl implements StuService {
|
|||
@Override
|
||||
public ServerResult<Integer> deleteStuByIds(Long[] ids) {
|
||||
try {
|
||||
//todo 批量删除子表数据
|
||||
stuDao.deleteResultsByIds(ids);
|
||||
//批量删除子表数据
|
||||
stuDao.deleteResultsBySIds(ids);
|
||||
Integer renewal = stuDao.deleteStuByIds(ids);
|
||||
if (renewal >0){
|
||||
return new ServerResult<Integer>(true,renewal);
|
||||
|
|
@ -160,7 +163,7 @@ public class StuServiceImpl implements StuService {
|
|||
@Override
|
||||
public ServerResult<Integer> deleteStuById(Long id) {
|
||||
try {
|
||||
//todo 删除子表数据
|
||||
//删除子表数据
|
||||
stuDao.deleteResultsBySId(id);
|
||||
Integer renewal = stuDao.deleteStuById(id);
|
||||
if (renewal >0){
|
||||
|
|
@ -185,7 +188,7 @@ public class StuServiceImpl implements StuService {
|
|||
if (StringUtils.isNotNull(resultsList)) {
|
||||
List<Results> list = new ArrayList<Results>();
|
||||
for (Results results : resultsList){
|
||||
results.setSId(id);
|
||||
results.setsId(id);
|
||||
list.add(results);
|
||||
}
|
||||
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>
|
||||
|
|
@ -23,6 +23,8 @@
|
|||
<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="selectStuVo">
|
||||
|
|
@ -41,7 +43,7 @@
|
|||
|
||||
<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,
|
||||
b.id, b.s_id, b.java
|
||||
b.id, b.s_id, b.java, b.images, b.file
|
||||
from sys_stu a
|
||||
left join sys_results b on b.s_id = a.id
|
||||
where a.id = #{id}
|
||||
|
|
@ -50,18 +52,18 @@
|
|||
<insert id="insertStu" parameterType="Stu" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sys_stu
|
||||
<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="email != null">email,</if>
|
||||
<if test="email != null and email != ''">email,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
</trim>
|
||||
<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="email != null">#{email},</if>
|
||||
<if test="email != null and email != ''">#{email},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
|
|
@ -72,9 +74,9 @@
|
|||
<update id="updateStu" parameterType="Stu">
|
||||
update sys_stu
|
||||
<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="email != null">email = #{email},</if>
|
||||
<if test="email != null and email != ''">email = #{email},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
|
|
@ -106,9 +108,9 @@
|
|||
</delete>
|
||||
|
||||
<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=",">
|
||||
( #{item.sId}, #{item.java})
|
||||
(#{item.sId},#{item.java},#{item.images},#{item.file})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue