This commit is contained in:
parent
d3c764f98c
commit
2adae0e122
|
|
@ -0,0 +1,66 @@
|
||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
|
||||||
|
// 查询文件信息列表
|
||||||
|
export function listFile(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/file/list',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出文件信息
|
||||||
|
export function exportFile(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/file/export',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询文件信息详细
|
||||||
|
export function getFile(fileId) {
|
||||||
|
return request({
|
||||||
|
url: '/system/file/' + fileId,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增文件信息
|
||||||
|
export function addFile(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/file',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改文件信息
|
||||||
|
export function updateFile(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/file',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除文件信息
|
||||||
|
export function delFile(fileId) {
|
||||||
|
return request({
|
||||||
|
url: '/system/file/' + fileId,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取角色选择框列表
|
||||||
|
export function getRoleAll(){
|
||||||
|
return request({
|
||||||
|
url:'/system/role/optionselect',
|
||||||
|
method:'get',
|
||||||
|
params:{
|
||||||
|
type:2
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -43,6 +43,7 @@ import { getToken } from "@/utils/auth";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
|
||||||
// 值
|
// 值
|
||||||
value: [String, Object, Array],
|
value: [String, Object, Array],
|
||||||
// 大小限制(MB)
|
// 大小限制(MB)
|
||||||
|
|
@ -110,7 +111,7 @@ export default {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
if (!isTypeOk) {
|
if (!isTypeOk) {
|
||||||
this.$message.error(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
|
this.$message.error('文件格式不正确, 请上传${this.fileType.join("/")}格式文件!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -118,7 +119,7 @@ export default {
|
||||||
if (this.fileSize) {
|
if (this.fileSize) {
|
||||||
const isLt = file.size / 1024 / 1024 < this.fileSize;
|
const isLt = file.size / 1024 / 1024 < this.fileSize;
|
||||||
if (!isLt) {
|
if (!isLt) {
|
||||||
this.$message.error(`上传文件大小不能超过 ${this.fileSize} MB!`);
|
this.$message.error('提交文件大小不能超过 ${this.fileSize} MB!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -126,16 +127,17 @@ export default {
|
||||||
},
|
},
|
||||||
// 文件个数超出
|
// 文件个数超出
|
||||||
handleExceed() {
|
handleExceed() {
|
||||||
this.$message.error(`只允许上传单个文件`);
|
this.$message.error('只允许提交单个文件');
|
||||||
},
|
},
|
||||||
// 上传失败
|
// 上传失败
|
||||||
handleUploadError(err) {
|
handleUploadError(err) {
|
||||||
this.$message.error("上传失败, 请重试");
|
this.$message.error("提交失败!, 请重试");
|
||||||
},
|
},
|
||||||
// 上传成功回调
|
// 上传成功回调
|
||||||
handleUploadSuccess(res, file) {
|
handleUploadSuccess(res, file) {
|
||||||
this.$message.success("上传成功");
|
this.$message.success("提交成功!");
|
||||||
this.$emit("input", res.url);
|
this.$emit("input", res.url);
|
||||||
|
this.$emit("changeAddress",res.fileName);
|
||||||
},
|
},
|
||||||
// 删除文件
|
// 删除文件
|
||||||
handleDelete(index) {
|
handleDelete(index) {
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ export default {
|
||||||
},
|
},
|
||||||
handleUploadSuccess(res) {
|
handleUploadSuccess(res) {
|
||||||
this.$emit("input", res.url);
|
this.$emit("input", res.url);
|
||||||
|
this.$emit("changeAddress",res.fileName);
|
||||||
this.loading.close();
|
this.loading.close();
|
||||||
},
|
},
|
||||||
handleBeforeUpload() {
|
handleBeforeUpload() {
|
||||||
|
|
@ -73,7 +74,7 @@ export default {
|
||||||
handleUploadError() {
|
handleUploadError() {
|
||||||
this.$message({
|
this.$message({
|
||||||
type: "error",
|
type: "error",
|
||||||
message: "上传失败",
|
message: "提交失败!",
|
||||||
});
|
});
|
||||||
this.loading.close();
|
this.loading.close();
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,441 @@
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="文件名称" prop="fileName">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.fileName"
|
||||||
|
placeholder="请输入文件名称"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="文件路径" prop="fileAddr">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.fileAddr"
|
||||||
|
placeholder="请输入文件路径"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="文件类型" prop="fileType">
|
||||||
|
<el-select v-model="queryParams.fileType" placeholder="请选择文件类型" clearable size="small">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in fileTypeOptions"
|
||||||
|
:key="dict.dictValue"
|
||||||
|
:label="dict.dictLabel"
|
||||||
|
:value="dict.dictValue"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="是否公开" prop="isPublic">
|
||||||
|
<el-select v-model="queryParams.isPublic" placeholder="请选择是否公开" clearable size="small">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in isPublicOptions"
|
||||||
|
:key="dict.dictValue"
|
||||||
|
:label="dict.dictLabel"
|
||||||
|
:value="dict.dictValue"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="创建时间">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="daterangeCreateTime"
|
||||||
|
size="small"
|
||||||
|
style="width: 240px"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<!-- <el-col :span="1.5">-->
|
||||||
|
<!-- <el-button-->
|
||||||
|
<!-- type="primary"-->
|
||||||
|
<!-- plain-->
|
||||||
|
<!-- icon="el-icon-plus"-->
|
||||||
|
<!-- size="mini"-->
|
||||||
|
<!-- @click="handleAdd"-->
|
||||||
|
<!-- v-hasPermi="['system:file:add']"-->
|
||||||
|
<!-- >新增</el-button>-->
|
||||||
|
<!-- </el-col>-->
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
icon="el-icon-edit"
|
||||||
|
size="mini"
|
||||||
|
@click="handleFileUpdate"
|
||||||
|
v-hasPermi="['system:file:edit']"
|
||||||
|
>文件上传
|
||||||
|
</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="['system:file: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="['system:file: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="['system:file:export']"
|
||||||
|
>导出
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="fileList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center"/>
|
||||||
|
<el-table-column label="文件名称" align="center" prop="fileName"/>
|
||||||
|
<el-table-column label="文件路径" align="center" prop="fileAddr"/>
|
||||||
|
<el-table-column label="文件类型" align="center" prop="fileType" :formatter="fileTypeFormat"/>
|
||||||
|
<el-table-column label="文件大小(MB)" align="center" prop="fileSize"/>
|
||||||
|
<el-table-column label="是否公开" align="center" prop="isPublic" :formatter="isPublicFormat"/>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="更新时间" align="center" prop="updateTime" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
@click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['system:file:edit']"
|
||||||
|
>修改
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['system:file:remove']"
|
||||||
|
>删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
|
:total="total"
|
||||||
|
:page.sync="queryParams.params.pageNum"
|
||||||
|
:limit.sync="queryParams.params.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<el-dialog :title="fileForm.title" :visible.sync="fileForm.open" width="500px" append-to-body>
|
||||||
|
<el-form ref="uploadFrom" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="角色">
|
||||||
|
<el-select v-model="form.roleIds" multiple placeholder="请选择">
|
||||||
|
<el-option
|
||||||
|
v-for="item in roleOptions"
|
||||||
|
:key="item.roleId"
|
||||||
|
:label="item.roleName"
|
||||||
|
:value="item.roleId"
|
||||||
|
:disabled="item.status == 1"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="是否保护">
|
||||||
|
<el-radio-group v-model="form.isPublic">
|
||||||
|
<el-radio label="1">不保护</el-radio>
|
||||||
|
<el-radio label="2">保护</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<div v-show="isAdd">
|
||||||
|
<el-form-item v-show="isAdd" label="文件类型">
|
||||||
|
<el-switch
|
||||||
|
v-model="fileForm.fileType"
|
||||||
|
active-text="文件"
|
||||||
|
inactive-text="图片" @change="fileTypeChange">
|
||||||
|
</el-switch>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="图片上传" v-show="!fileForm.fileType">
|
||||||
|
<ImageUpload v-model="fileForm.url" v-on:changeAddress="changeAddress"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="文件上传" v-show="fileForm.fileType">
|
||||||
|
<FileUpload v-model="fileForm.url" v-on:changeAddress="changeAddress"/>
|
||||||
|
</el-form-item>
|
||||||
|
</div>
|
||||||
|
</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 {listFile, getFile, delFile, addFile, updateFile, exportFile, getRoleAll} from "@/api/system/file";
|
||||||
|
import ImageUpload from '@/components/ImageUpload';
|
||||||
|
import FileUpload from '@/components/FileUpload';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "File",
|
||||||
|
components: {
|
||||||
|
ImageUpload,
|
||||||
|
FileUpload,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
fileForm: {
|
||||||
|
title: "",
|
||||||
|
url: "",
|
||||||
|
open: false,
|
||||||
|
fileType: false,
|
||||||
|
isPulic: false,
|
||||||
|
},
|
||||||
|
// 角色选项
|
||||||
|
roleOptions: [],
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 文件信息表格数据
|
||||||
|
fileList: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
isAdd: true,
|
||||||
|
// 文件类型(文件夹:folder,文件:file)字典
|
||||||
|
fileTypeOptions: [],
|
||||||
|
// 是否公开字典
|
||||||
|
isPublicOptions: [],
|
||||||
|
// 创建时间时间范围
|
||||||
|
daterangeCreateTime: [],
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
params: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
},
|
||||||
|
fileName: null,
|
||||||
|
fileAddr: null,
|
||||||
|
fileType: null,
|
||||||
|
isPublic: null,
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 表单校验
|
||||||
|
rules: {}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
this.getDicts("sys_fIle_type").then(response => {
|
||||||
|
this.fileTypeOptions = response.data;
|
||||||
|
});
|
||||||
|
this.getDicts("sys_file_public").then(response => {
|
||||||
|
this.isPublicOptions = response.data;
|
||||||
|
});
|
||||||
|
getRoleAll().then(res => {
|
||||||
|
console.log(res)
|
||||||
|
this.roleOptions = res.data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询文件信息列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
|
||||||
|
this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0];
|
||||||
|
this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
|
||||||
|
}
|
||||||
|
listFile(this.queryParams).then(response => {
|
||||||
|
this.fileList = response.rows;
|
||||||
|
this.total = response.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
fileTypeChange() {
|
||||||
|
this.form.fileAddr = ""
|
||||||
|
this.fileForm.url = ""
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 改变地址
|
||||||
|
*/
|
||||||
|
changeAddress(addr) {
|
||||||
|
this.form.fileAddr = addr
|
||||||
|
console.log(addr)
|
||||||
|
},
|
||||||
|
/** 文件上传 */
|
||||||
|
handleFileUpdate() {
|
||||||
|
this.reset()
|
||||||
|
this.isAdd = true
|
||||||
|
this.fileForm.title = "文件上传"
|
||||||
|
this.fileForm.open = true
|
||||||
|
},
|
||||||
|
// 文件类型字典翻译
|
||||||
|
fileTypeFormat(row, column) {
|
||||||
|
return this.selectDictLabel(this.fileTypeOptions, row.fileType);
|
||||||
|
},
|
||||||
|
// 是否公开字典翻译
|
||||||
|
isPublicFormat(row, column) {
|
||||||
|
return this.selectDictLabel(this.isPublicOptions, row.isPublic);
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.fileForm.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
fileId: null,
|
||||||
|
pId: null,
|
||||||
|
roleIds: null,
|
||||||
|
fileName: null,
|
||||||
|
mapping: null,
|
||||||
|
fileAddr: null,
|
||||||
|
fileType: null,
|
||||||
|
isPublic: "1",
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.daterangeCreateTime = [];
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.fileId)
|
||||||
|
this.single = selection.length !== 1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.reset();
|
||||||
|
this.open = true;
|
||||||
|
this.title = "添加文件信息";
|
||||||
|
},
|
||||||
|
changeArray() {
|
||||||
|
let roleIds = this.form.roleIds.split(",")
|
||||||
|
this.form.roleIds = []
|
||||||
|
for (let i = 0; i < roleIds.length; i++) {
|
||||||
|
this.form.roleIds[i] = parseInt(roleIds[i])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset();
|
||||||
|
this.isAdd = false
|
||||||
|
const fileId = row.fileId || this.ids
|
||||||
|
getFile(fileId).then(response => {
|
||||||
|
this.form = response.data;
|
||||||
|
this.changeArray()
|
||||||
|
this.fileForm.open = true;
|
||||||
|
this.fileForm.title = "修改文件信息";
|
||||||
|
console.log(this.form)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm() {
|
||||||
|
let roleIds = ""
|
||||||
|
for (let i = 0; i < this.form.roleIds.length; i++) {
|
||||||
|
roleIds += this.form.roleIds[i]
|
||||||
|
if (i < this.form.roleIds.length - 1) {
|
||||||
|
roleIds += ","
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.form.roleIds = roleIds
|
||||||
|
if (this.form.fileId != null) {
|
||||||
|
updateFile(this.form).then(response => {
|
||||||
|
this.msgSuccess("修改成功");
|
||||||
|
this.fileForm.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addFile(this.form).then(response => {
|
||||||
|
this.msgSuccess("新增成功");
|
||||||
|
this.fileForm.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const fileIds = row.fileId || this.ids;
|
||||||
|
this.$confirm('是否确认删除文件信息编号为"' + fileIds + '"的数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function () {
|
||||||
|
return delFile(fileIds);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.msgSuccess("删除成功");
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
const queryParams = this.queryParams;
|
||||||
|
this.$confirm('是否确认导出所有文件信息数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function () {
|
||||||
|
return exportFile(queryParams);
|
||||||
|
}).then(response => {
|
||||||
|
this.download(response.msg);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
@ -72,6 +72,7 @@ public class CommonController {
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
ajax.put("fileName" , fileName);
|
ajax.put("fileName" , fileName);
|
||||||
ajax.put("url" , url);
|
ajax.put("url" , url);
|
||||||
|
ajax.put("addres","/test");
|
||||||
return ajax;
|
return ajax;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return AjaxResult.error(e.getMessage());
|
return AjaxResult.error(e.getMessage());
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,183 @@
|
||||||
|
package com.hchyun.web.controller.system;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
import com.hchyun.common.constant.ReturnConstants;
|
||||||
|
import com.hchyun.common.core.controller.HcyBaseController;
|
||||||
|
import com.hchyun.common.utils.ServerResult;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
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.system.entity.File;
|
||||||
|
import com.hchyun.system.service.FileService;
|
||||||
|
import com.hchyun.common.utils.poi.ExcelUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件信息Controller
|
||||||
|
*
|
||||||
|
* @author hchyun
|
||||||
|
* @date 2021-02-17
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Api(value = "文件信息管理",tags = "文件信息管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/file")
|
||||||
|
public class FileController extends HcyBaseController {
|
||||||
|
protected final Logger logger = LoggerFactory.getLogger(FileController.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FileService fileService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询文件信息列表
|
||||||
|
*/
|
||||||
|
@ApiOperation("查询文件信息列表")
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:file:list')")
|
||||||
|
@PutMapping("/list")
|
||||||
|
public Serializable list(@Validated @RequestBody File file) {
|
||||||
|
try {
|
||||||
|
startPage(file.getParams());
|
||||||
|
ServerResult<List<File>> serverResult = fileService.selectFileList(file);
|
||||||
|
if (serverResult.isStart()) {
|
||||||
|
return getDataTable(serverResult.getData());
|
||||||
|
} else {
|
||||||
|
return AjaxResult.info(serverResult.getMsg());
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出文件信息列表
|
||||||
|
*/
|
||||||
|
@ApiOperation("导出文件信息列表")
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:file:export')")
|
||||||
|
@Log(title = "文件信息", businessType = BusinessType.EXPORT)
|
||||||
|
@PutMapping("/export")
|
||||||
|
public AjaxResult export(@Validated @RequestBody File file) {
|
||||||
|
try {
|
||||||
|
ServerResult<List<File>> serverResult = fileService.selectFileList(file);
|
||||||
|
ExcelUtil<File> util = new ExcelUtil<File>(File. class);
|
||||||
|
if (serverResult.isStart()) {
|
||||||
|
return util.exportExcel(serverResult.getData(), "file");
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error(serverResult.getMsg());
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件信息详细信息
|
||||||
|
*/
|
||||||
|
@ApiOperation("获取文件信息详细信息")
|
||||||
|
@ApiImplicitParam(name = "fileId" , value = "文件信息fileId" , required = true, dataType = "Long" , paramType = "path")
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:file:query')")
|
||||||
|
@GetMapping(value = "/{fileId}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("fileId") Long fileId) {
|
||||||
|
try {
|
||||||
|
ServerResult<File> serverResult = fileService.selectFileById(fileId);
|
||||||
|
if (serverResult.isStart()) {
|
||||||
|
return AjaxResult.success(serverResult.getData());
|
||||||
|
} else {
|
||||||
|
return AjaxResult.info(serverResult.getMsg());
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增文件信息
|
||||||
|
*/
|
||||||
|
@ApiOperation("新增文件信息")
|
||||||
|
@ApiImplicitParam(name = "file" , value = "新增文件信息信息" , dataType = "File")
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:file:add')")
|
||||||
|
@Log(title = "文件信息", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody File file) {
|
||||||
|
try {
|
||||||
|
ServerResult<Integer> serverResult = fileService.insertFile(file);
|
||||||
|
if (serverResult.isStart()) {
|
||||||
|
return AjaxResult.success();
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error(serverResult.getMsg());
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改文件信息
|
||||||
|
*/
|
||||||
|
@ApiOperation("修改文件信息")
|
||||||
|
@ApiImplicitParam(name = "file" , value = "修改文件信息信息" , dataType = "File")
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:file:edit')")
|
||||||
|
@Log(title = "文件信息", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody File file) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
ServerResult<Integer> serverResult = fileService.updateFile(file);
|
||||||
|
if (serverResult.isStart()) {
|
||||||
|
return AjaxResult.success();
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error(serverResult.getMsg());
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文件信息
|
||||||
|
*/
|
||||||
|
@ApiOperation("删除文件信息")
|
||||||
|
@ApiImplicitParam(name = "fileIds" , value = "文件信息fileIds" , required = true, dataType = "Long" , paramType = "path")
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:file:remove')")
|
||||||
|
@Log(title = "文件信息", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{fileIds}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] fileIds) {
|
||||||
|
try {
|
||||||
|
if (fileIds.length<0){
|
||||||
|
return AjaxResult.error("id不能为空!");
|
||||||
|
}
|
||||||
|
ServerResult<Integer> serverResult = fileService.deleteFileByIds(fileIds);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ package com.hchyun.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.hchyun.common.constant.ReturnConstants;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -30,6 +31,8 @@ import com.hchyun.framework.web.service.TokenService;
|
||||||
import com.hchyun.system.service.ISysRoleService;
|
import com.hchyun.system.service.ISysRoleService;
|
||||||
import com.hchyun.system.service.ISysUserService;
|
import com.hchyun.system.service.ISysUserService;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色信息
|
* 角色信息
|
||||||
*
|
*
|
||||||
|
|
@ -159,7 +162,11 @@ public class SysRoleController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||||
@GetMapping("/optionselect")
|
@GetMapping("/optionselect")
|
||||||
public AjaxResult optionselect() {
|
public AjaxResult optionselect(Integer type) {
|
||||||
return AjaxResult.success(roleService.selectRoleAll());
|
if (type == 1 || type == 2) {
|
||||||
|
return AjaxResult.success(roleService.selectRoleAll(type));
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error(ReturnConstants.STATE_ERROR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ public class SysUserController extends BaseController {
|
||||||
@GetMapping(value = {"/" , "/{userId}"})
|
@GetMapping(value = {"/" , "/{userId}"})
|
||||||
public AjaxResult getInfo(@PathVariable(value = "userId" , required = false) Long userId) {
|
public AjaxResult getInfo(@PathVariable(value = "userId" , required = false) Long userId) {
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
List<SysRole> roles = roleService.selectRoleAll();
|
List<SysRole> roles = roleService.selectRoleAll(1);
|
||||||
ajax.put("roles" , SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
ajax.put("roles" , SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||||
ajax.put("posts" , postService.selectPostAll());
|
ajax.put("posts" , postService.selectPostAll());
|
||||||
if (StringUtils.isNotNull(userId)) {
|
if (StringUtils.isNotNull(userId)) {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.hchyun.common.core.entity.entity;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
import com.hchyun.common.annotation.Excel;
|
import com.hchyun.common.annotation.Excel;
|
||||||
|
|
@ -13,214 +14,222 @@ import com.hchyun.common.core.entity.BaseEntity;
|
||||||
*
|
*
|
||||||
* @author hchyun
|
* @author hchyun
|
||||||
*/
|
*/
|
||||||
public class SysRole extends BaseEntity
|
public class SysRole extends BaseEntity {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
/** 角色ID */
|
/**
|
||||||
@Excel(name = "角色序号", cellType = ColumnType.NUMERIC)
|
* 角色ID
|
||||||
|
*/
|
||||||
|
@Excel(name = "角色序号" , cellType = ColumnType.NUMERIC)
|
||||||
private Long roleId;
|
private Long roleId;
|
||||||
|
|
||||||
/** 角色名称 */
|
/**
|
||||||
|
* 角色名称
|
||||||
|
*/
|
||||||
@Excel(name = "角色名称")
|
@Excel(name = "角色名称")
|
||||||
private String roleName;
|
private String roleName;
|
||||||
|
|
||||||
/** 角色权限 */
|
/**
|
||||||
|
* 角色权限
|
||||||
|
*/
|
||||||
@Excel(name = "角色权限")
|
@Excel(name = "角色权限")
|
||||||
private String roleKey;
|
private String roleKey;
|
||||||
|
|
||||||
/** 角色排序 */
|
/**
|
||||||
|
* 角色排序
|
||||||
|
*/
|
||||||
@Excel(name = "角色排序")
|
@Excel(name = "角色排序")
|
||||||
private String roleSort;
|
private String roleSort;
|
||||||
|
|
||||||
/** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限) */
|
/**
|
||||||
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限")
|
* 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限)
|
||||||
|
*/
|
||||||
|
@Excel(name = "数据范围" , readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限")
|
||||||
private String dataScope;
|
private String dataScope;
|
||||||
|
|
||||||
/** 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) */
|
/**
|
||||||
|
* 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示)
|
||||||
|
*/
|
||||||
private boolean menuCheckStrictly;
|
private boolean menuCheckStrictly;
|
||||||
|
|
||||||
/** 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 ) */
|
/**
|
||||||
|
* 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 )
|
||||||
|
*/
|
||||||
private boolean deptCheckStrictly;
|
private boolean deptCheckStrictly;
|
||||||
|
|
||||||
/** 角色状态(0正常 1停用) */
|
/**
|
||||||
@Excel(name = "角色状态", readConverterExp = "0=正常,1=停用")
|
* 角色状态(0正常 1停用)
|
||||||
|
*/
|
||||||
|
@Excel(name = "角色状态" , readConverterExp = "0=正常,1=停用")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/** 删除标志(0代表存在 2代表删除) */
|
/**
|
||||||
|
* 删除标志(0代表存在 2代表删除)
|
||||||
|
*/
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
/** 用户是否存在此角色标识 默认不存在 */
|
/**
|
||||||
|
* 用户是否存在此角色标识 默认不存在
|
||||||
|
*/
|
||||||
private boolean flag = false;
|
private boolean flag = false;
|
||||||
|
|
||||||
/** 菜单组 */
|
/**
|
||||||
|
* 菜单组
|
||||||
|
*/
|
||||||
private Long[] menuIds;
|
private Long[] menuIds;
|
||||||
|
|
||||||
/** 部门组(数据权限) */
|
/**
|
||||||
|
* 部门组(数据权限)
|
||||||
|
*/
|
||||||
private Long[] deptIds;
|
private Long[] deptIds;
|
||||||
|
|
||||||
public SysRole()
|
private Integer roleType = 1;
|
||||||
{
|
|
||||||
|
|
||||||
|
public SysRole() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SysRole(Long roleId)
|
public SysRole(Integer roleType) {
|
||||||
{
|
this.roleType = roleType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getRoleType() {
|
||||||
|
return roleType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleType(Integer roleType) {
|
||||||
|
this.roleType = roleType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SysRole(Long roleId) {
|
||||||
this.roleId = roleId;
|
this.roleId = roleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getRoleId()
|
public Long getRoleId() {
|
||||||
{
|
|
||||||
return roleId;
|
return roleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRoleId(Long roleId)
|
public void setRoleId(Long roleId) {
|
||||||
{
|
|
||||||
this.roleId = roleId;
|
this.roleId = roleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAdmin()
|
public boolean isAdmin() {
|
||||||
{
|
|
||||||
return isAdmin(this.roleId);
|
return isAdmin(this.roleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAdmin(Long roleId)
|
public static boolean isAdmin(Long roleId) {
|
||||||
{
|
|
||||||
return roleId != null && 1L == roleId;
|
return roleId != null && 1L == roleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotBlank(message = "角色名称不能为空")
|
@NotBlank(message = "角色名称不能为空")
|
||||||
@Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
|
@Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
|
||||||
public String getRoleName()
|
public String getRoleName() {
|
||||||
{
|
|
||||||
return roleName;
|
return roleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRoleName(String roleName)
|
public void setRoleName(String roleName) {
|
||||||
{
|
|
||||||
this.roleName = roleName;
|
this.roleName = roleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotBlank(message = "权限字符不能为空")
|
@NotBlank(message = "权限字符不能为空")
|
||||||
@Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
|
||||||
public String getRoleKey()
|
public String getRoleKey() {
|
||||||
{
|
|
||||||
return roleKey;
|
return roleKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRoleKey(String roleKey)
|
public void setRoleKey(String roleKey) {
|
||||||
{
|
|
||||||
this.roleKey = roleKey;
|
this.roleKey = roleKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotBlank(message = "显示顺序不能为空")
|
@NotBlank(message = "显示顺序不能为空")
|
||||||
public String getRoleSort()
|
public String getRoleSort() {
|
||||||
{
|
|
||||||
return roleSort;
|
return roleSort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRoleSort(String roleSort)
|
public void setRoleSort(String roleSort) {
|
||||||
{
|
|
||||||
this.roleSort = roleSort;
|
this.roleSort = roleSort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDataScope()
|
public String getDataScope() {
|
||||||
{
|
|
||||||
return dataScope;
|
return dataScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataScope(String dataScope)
|
public void setDataScope(String dataScope) {
|
||||||
{
|
|
||||||
this.dataScope = dataScope;
|
this.dataScope = dataScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMenuCheckStrictly()
|
public boolean isMenuCheckStrictly() {
|
||||||
{
|
|
||||||
return menuCheckStrictly;
|
return menuCheckStrictly;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMenuCheckStrictly(boolean menuCheckStrictly)
|
public void setMenuCheckStrictly(boolean menuCheckStrictly) {
|
||||||
{
|
|
||||||
this.menuCheckStrictly = menuCheckStrictly;
|
this.menuCheckStrictly = menuCheckStrictly;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDeptCheckStrictly()
|
public boolean isDeptCheckStrictly() {
|
||||||
{
|
|
||||||
return deptCheckStrictly;
|
return deptCheckStrictly;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeptCheckStrictly(boolean deptCheckStrictly)
|
public void setDeptCheckStrictly(boolean deptCheckStrictly) {
|
||||||
{
|
|
||||||
this.deptCheckStrictly = deptCheckStrictly;
|
this.deptCheckStrictly = deptCheckStrictly;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStatus()
|
public String getStatus() {
|
||||||
{
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatus(String status)
|
public void setStatus(String status) {
|
||||||
{
|
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDelFlag()
|
public String getDelFlag() {
|
||||||
{
|
|
||||||
return delFlag;
|
return delFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDelFlag(String delFlag)
|
public void setDelFlag(String delFlag) {
|
||||||
{
|
|
||||||
this.delFlag = delFlag;
|
this.delFlag = delFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFlag()
|
public boolean isFlag() {
|
||||||
{
|
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlag(boolean flag)
|
public void setFlag(boolean flag) {
|
||||||
{
|
|
||||||
this.flag = flag;
|
this.flag = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long[] getMenuIds()
|
public Long[] getMenuIds() {
|
||||||
{
|
|
||||||
return menuIds;
|
return menuIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMenuIds(Long[] menuIds)
|
public void setMenuIds(Long[] menuIds) {
|
||||||
{
|
|
||||||
this.menuIds = menuIds;
|
this.menuIds = menuIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long[] getDeptIds()
|
public Long[] getDeptIds() {
|
||||||
{
|
|
||||||
return deptIds;
|
return deptIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeptIds(Long[] deptIds)
|
public void setDeptIds(Long[] deptIds) {
|
||||||
{
|
|
||||||
this.deptIds = deptIds;
|
this.deptIds = deptIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||||
.append("roleId", getRoleId())
|
.append("roleId" , getRoleId())
|
||||||
.append("roleName", getRoleName())
|
.append("roleName" , getRoleName())
|
||||||
.append("roleKey", getRoleKey())
|
.append("roleKey" , getRoleKey())
|
||||||
.append("roleSort", getRoleSort())
|
.append("roleSort" , getRoleSort())
|
||||||
.append("dataScope", getDataScope())
|
.append("dataScope" , getDataScope())
|
||||||
.append("menuCheckStrictly", isMenuCheckStrictly())
|
.append("menuCheckStrictly" , isMenuCheckStrictly())
|
||||||
.append("deptCheckStrictly", isDeptCheckStrictly())
|
.append("deptCheckStrictly" , isDeptCheckStrictly())
|
||||||
.append("status", getStatus())
|
.append("status" , getStatus())
|
||||||
.append("delFlag", getDelFlag())
|
.append("delFlag" , getDelFlag())
|
||||||
.append("createBy", getCreateBy())
|
.append("createBy" , getCreateBy())
|
||||||
.append("createTime", getCreateTime())
|
.append("createTime" , getCreateTime())
|
||||||
.append("updateBy", getUpdateBy())
|
.append("updateBy" , getUpdateBy())
|
||||||
.append("updateTime", getUpdateTime())
|
.append("updateTime" , getUpdateTime())
|
||||||
.append("remark", getRemark())
|
.append("remark" , getRemark())
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,10 @@ public class FileUploadUtils {
|
||||||
public static final String extractFilename(MultipartFile file) {
|
public static final String extractFilename(MultipartFile file) {
|
||||||
String fileName = file.getOriginalFilename();
|
String fileName = file.getOriginalFilename();
|
||||||
String extension = getExtension(file);
|
String extension = getExtension(file);
|
||||||
fileName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension;
|
|
||||||
|
fileName = DateUtils.datePath() + "/" + fileName;
|
||||||
|
// todo IdUtils.fastUUID() 获取文件映射名
|
||||||
|
// fileName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension;
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -125,6 +128,13 @@ public class FileUploadUtils {
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param uploadDir
|
||||||
|
* @param fileName
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
private static final String getPathFileName(String uploadDir, String fileName) throws IOException {
|
private static final String getPathFileName(String uploadDir, String fileName) throws IOException {
|
||||||
int dirLastIndex = HchYunConfig.getProfile().length() + 1;
|
int dirLastIndex = HchYunConfig.getProfile().length() + 1;
|
||||||
String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
|
String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
|
||||||
|
|
@ -163,7 +173,6 @@ public class FileUploadUtils {
|
||||||
throw new InvalidExtensionException(allowedExtension, extension, fileName);
|
throw new InvalidExtensionException(allowedExtension, extension, fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
@ -26,8 +27,7 @@ import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
* @author hchyun
|
* @author hchyun
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class TokenService
|
public class TokenService {
|
||||||
{
|
|
||||||
// 令牌自定义标识
|
// 令牌自定义标识
|
||||||
@Value("${token.header}")
|
@Value("${token.header}")
|
||||||
private String header;
|
private String header;
|
||||||
|
|
@ -54,12 +54,10 @@ public class TokenService
|
||||||
*
|
*
|
||||||
* @return 用户信息
|
* @return 用户信息
|
||||||
*/
|
*/
|
||||||
public LoginUser getLoginUser(HttpServletRequest request)
|
public LoginUser getLoginUser(HttpServletRequest request) {
|
||||||
{
|
|
||||||
// 获取请求携带的令牌
|
// 获取请求携带的令牌
|
||||||
String token = getToken(request);
|
String token = getToken(request);
|
||||||
if (StringUtils.isNotEmpty(token))
|
if (StringUtils.isNotEmpty(token)) {
|
||||||
{
|
|
||||||
Claims claims = parseToken(token);
|
Claims claims = parseToken(token);
|
||||||
// 解析对应的权限以及用户信息
|
// 解析对应的权限以及用户信息
|
||||||
String uuid = (String) claims.get(Constants.LOGIN_USER_KEY);
|
String uuid = (String) claims.get(Constants.LOGIN_USER_KEY);
|
||||||
|
|
@ -73,10 +71,8 @@ public class TokenService
|
||||||
/**
|
/**
|
||||||
* 设置用户身份信息
|
* 设置用户身份信息
|
||||||
*/
|
*/
|
||||||
public void setLoginUser(LoginUser loginUser)
|
public void setLoginUser(LoginUser loginUser) {
|
||||||
{
|
if (StringUtils.isNotNull(loginUser) && StringUtils.isNotEmpty(loginUser.getToken())) {
|
||||||
if (StringUtils.isNotNull(loginUser) && StringUtils.isNotEmpty(loginUser.getToken()))
|
|
||||||
{
|
|
||||||
refreshToken(loginUser);
|
refreshToken(loginUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -84,10 +80,8 @@ public class TokenService
|
||||||
/**
|
/**
|
||||||
* 删除用户身份信息
|
* 删除用户身份信息
|
||||||
*/
|
*/
|
||||||
public void delLoginUser(String token)
|
public void delLoginUser(String token) {
|
||||||
{
|
if (StringUtils.isNotEmpty(token)) {
|
||||||
if (StringUtils.isNotEmpty(token))
|
|
||||||
{
|
|
||||||
String userKey = getTokenKey(token);
|
String userKey = getTokenKey(token);
|
||||||
redisCache.deleteObject(userKey);
|
redisCache.deleteObject(userKey);
|
||||||
}
|
}
|
||||||
|
|
@ -99,8 +93,7 @@ public class TokenService
|
||||||
* @param loginUser 用户信息
|
* @param loginUser 用户信息
|
||||||
* @return 令牌
|
* @return 令牌
|
||||||
*/
|
*/
|
||||||
public String createToken(LoginUser loginUser)
|
public String createToken(LoginUser loginUser) {
|
||||||
{
|
|
||||||
String token = IdUtils.fastUUID();
|
String token = IdUtils.fastUUID();
|
||||||
loginUser.setToken(token);
|
loginUser.setToken(token);
|
||||||
setUserAgent(loginUser);
|
setUserAgent(loginUser);
|
||||||
|
|
@ -117,12 +110,10 @@ public class TokenService
|
||||||
* @param loginUser
|
* @param loginUser
|
||||||
* @return 令牌
|
* @return 令牌
|
||||||
*/
|
*/
|
||||||
public void verifyToken(LoginUser loginUser)
|
public void verifyToken(LoginUser loginUser) {
|
||||||
{
|
|
||||||
long expireTime = loginUser.getExpireTime();
|
long expireTime = loginUser.getExpireTime();
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
if (expireTime - currentTime <= MILLIS_MINUTE_TEN)
|
if (expireTime - currentTime <= MILLIS_MINUTE_TEN) {
|
||||||
{
|
|
||||||
refreshToken(loginUser);
|
refreshToken(loginUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -132,8 +123,7 @@ public class TokenService
|
||||||
*
|
*
|
||||||
* @param loginUser 登录信息
|
* @param loginUser 登录信息
|
||||||
*/
|
*/
|
||||||
public void refreshToken(LoginUser loginUser)
|
public void refreshToken(LoginUser loginUser) {
|
||||||
{
|
|
||||||
loginUser.setLoginTime(System.currentTimeMillis());
|
loginUser.setLoginTime(System.currentTimeMillis());
|
||||||
loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE);
|
loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE);
|
||||||
// 根据uuid将loginUser缓存
|
// 根据uuid将loginUser缓存
|
||||||
|
|
@ -146,8 +136,7 @@ public class TokenService
|
||||||
*
|
*
|
||||||
* @param loginUser 登录信息
|
* @param loginUser 登录信息
|
||||||
*/
|
*/
|
||||||
public void setUserAgent(LoginUser loginUser)
|
public void setUserAgent(LoginUser loginUser) {
|
||||||
{
|
|
||||||
UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent"));
|
UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent"));
|
||||||
String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
|
String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
|
||||||
loginUser.setIpaddr(ip);
|
loginUser.setIpaddr(ip);
|
||||||
|
|
@ -162,8 +151,7 @@ public class TokenService
|
||||||
* @param claims 数据声明
|
* @param claims 数据声明
|
||||||
* @return 令牌
|
* @return 令牌
|
||||||
*/
|
*/
|
||||||
private String createToken(Map<String, Object> claims)
|
private String createToken(Map<String, Object> claims) {
|
||||||
{
|
|
||||||
String token = Jwts.builder()
|
String token = Jwts.builder()
|
||||||
.setClaims(claims)
|
.setClaims(claims)
|
||||||
.signWith(SignatureAlgorithm.HS512, secret).compact();
|
.signWith(SignatureAlgorithm.HS512, secret).compact();
|
||||||
|
|
@ -176,8 +164,7 @@ public class TokenService
|
||||||
* @param token 令牌
|
* @param token 令牌
|
||||||
* @return 数据声明
|
* @return 数据声明
|
||||||
*/
|
*/
|
||||||
private Claims parseToken(String token)
|
private Claims parseToken(String token) {
|
||||||
{
|
|
||||||
return Jwts.parser()
|
return Jwts.parser()
|
||||||
.setSigningKey(secret)
|
.setSigningKey(secret)
|
||||||
.parseClaimsJws(token)
|
.parseClaimsJws(token)
|
||||||
|
|
@ -190,8 +177,7 @@ public class TokenService
|
||||||
* @param token 令牌
|
* @param token 令牌
|
||||||
* @return 用户名
|
* @return 用户名
|
||||||
*/
|
*/
|
||||||
public String getUsernameFromToken(String token)
|
public String getUsernameFromToken(String token) {
|
||||||
{
|
|
||||||
Claims claims = parseToken(token);
|
Claims claims = parseToken(token);
|
||||||
return claims.getSubject();
|
return claims.getSubject();
|
||||||
}
|
}
|
||||||
|
|
@ -202,18 +188,15 @@ public class TokenService
|
||||||
* @param request
|
* @param request
|
||||||
* @return token
|
* @return token
|
||||||
*/
|
*/
|
||||||
private String getToken(HttpServletRequest request)
|
private String getToken(HttpServletRequest request) {
|
||||||
{
|
|
||||||
String token = request.getHeader(header);
|
String token = request.getHeader(header);
|
||||||
if (StringUtils.isNotEmpty(token) && token.startsWith(Constants.TOKEN_PREFIX))
|
if (StringUtils.isNotEmpty(token) && token.startsWith(Constants.TOKEN_PREFIX)) {
|
||||||
{
|
|
||||||
token = token.replace(Constants.TOKEN_PREFIX, "");
|
token = token.replace(Constants.TOKEN_PREFIX, "");
|
||||||
}
|
}
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTokenKey(String uuid)
|
private String getTokenKey(String uuid) {
|
||||||
{
|
|
||||||
return Constants.LOGIN_TOKEN_KEY + uuid;
|
return Constants.LOGIN_TOKEN_KEY + uuid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ public interface ${ClassName}Dao {
|
||||||
/**
|
/**
|
||||||
* 通过${functionName}ID删除${subTable.functionName}信息
|
* 通过${functionName}ID删除${subTable.functionName}信息
|
||||||
*
|
*
|
||||||
* @param roleId 角色ID
|
* @param roleIds 角色ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
|
int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.hchyun.system.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.hchyun.system.entity.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件信息Mapper接口
|
||||||
|
*
|
||||||
|
* @author hchyun
|
||||||
|
* @date 2021-02-17
|
||||||
|
*/
|
||||||
|
public interface FileDao {
|
||||||
|
/**
|
||||||
|
* 查询文件信息
|
||||||
|
*
|
||||||
|
* @param fileId 文件信息ID
|
||||||
|
* @return 文件信息
|
||||||
|
*/
|
||||||
|
File selectFileById(Long fileId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询文件信息列表
|
||||||
|
*
|
||||||
|
* @param file 文件信息
|
||||||
|
* @return 文件信息集合
|
||||||
|
*/
|
||||||
|
List<File> selectFileList(File file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增文件信息
|
||||||
|
*
|
||||||
|
* @param file 文件信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int insertFile(File file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改文件信息
|
||||||
|
*
|
||||||
|
* @param file 文件信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int updateFile(File file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文件信息
|
||||||
|
*
|
||||||
|
* @param fileId 文件信息ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteFileById(Long fileId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除文件信息
|
||||||
|
*
|
||||||
|
* @param fileIds 需要删除的数据ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteFileByIds(Long[] fileIds);
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.hchyun.system.dao;
|
package com.hchyun.system.dao;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.hchyun.common.core.entity.entity.SysRole;
|
import com.hchyun.common.core.entity.entity.SysRole;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -8,8 +9,7 @@ import com.hchyun.common.core.entity.entity.SysRole;
|
||||||
*
|
*
|
||||||
* @author hchyun
|
* @author hchyun
|
||||||
*/
|
*/
|
||||||
public interface SysRoleDao
|
public interface SysRoleDao {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询角色数据
|
* 根据条件分页查询角色数据
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,161 @@
|
||||||
|
package com.hchyun.system.entity;
|
||||||
|
|
||||||
|
import com.hchyun.common.annotation.Excel;
|
||||||
|
import com.hchyun.common.core.entity.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件信息对象 sys_file
|
||||||
|
*
|
||||||
|
* @author hchyun
|
||||||
|
* @date 2021-02-17
|
||||||
|
*/
|
||||||
|
@ApiModel("文件信息")
|
||||||
|
public class File extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件id
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("文件id")
|
||||||
|
private Long fileId;
|
||||||
|
/**
|
||||||
|
* 文件夹id
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("文件夹id")
|
||||||
|
private Long pId;
|
||||||
|
/**
|
||||||
|
* 角色id
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("角色id")
|
||||||
|
private String roleIds;
|
||||||
|
/**
|
||||||
|
* 文件名称
|
||||||
|
*/
|
||||||
|
@Excel(name = "文件名称")
|
||||||
|
@ApiModelProperty("文件名称")
|
||||||
|
private String fileName;
|
||||||
|
/**
|
||||||
|
* 映射名称
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("映射名称")
|
||||||
|
private String mapping;
|
||||||
|
/**
|
||||||
|
* 文件路径
|
||||||
|
*/
|
||||||
|
@Excel(name = "文件路径")
|
||||||
|
@ApiModelProperty("文件路径")
|
||||||
|
private String fileAddr;
|
||||||
|
/**
|
||||||
|
* 文件类型(文件夹:folder,文件:file)
|
||||||
|
*/
|
||||||
|
@Excel(name = "文件类型")
|
||||||
|
@ApiModelProperty("文件类型")
|
||||||
|
private String fileType;
|
||||||
|
/**
|
||||||
|
* 文件大小(MB)
|
||||||
|
*/
|
||||||
|
@Excel(name = "文件大小(MB)")
|
||||||
|
@ApiModelProperty("文件大小(MB)")
|
||||||
|
private String fileSize;
|
||||||
|
/**
|
||||||
|
* 是否公开
|
||||||
|
*/
|
||||||
|
@Excel(name = "是否公开")
|
||||||
|
@ApiModelProperty("是否公开")
|
||||||
|
private String isPublic;
|
||||||
|
|
||||||
|
|
||||||
|
public void setFileId(Long fileId) {
|
||||||
|
this.fileId = fileId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getFileId() {
|
||||||
|
return fileId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setpId(Long pId) {
|
||||||
|
this.pId = pId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getpId() {
|
||||||
|
return pId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoleIds() {
|
||||||
|
return roleIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleIds(String roleIds) {
|
||||||
|
this.roleIds = roleIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileName(String fileName) {
|
||||||
|
this.fileName = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileName() {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMapping(String mapping) {
|
||||||
|
this.mapping = mapping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMapping() {
|
||||||
|
return mapping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileAddr(String fileAddr) {
|
||||||
|
this.fileAddr = fileAddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileAddr() {
|
||||||
|
return fileAddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileType(String fileType) {
|
||||||
|
this.fileType = fileType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileType() {
|
||||||
|
return fileType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileSize(String fileSize) {
|
||||||
|
this.fileSize = fileSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileSize() {
|
||||||
|
return fileSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsPublic(String isPublic) {
|
||||||
|
this.isPublic = isPublic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIsPublic() {
|
||||||
|
return isPublic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("fileId" , getFileId())
|
||||||
|
.append("pId" , getpId())
|
||||||
|
.append("roleIds" , getRoleIds())
|
||||||
|
.append("fileName" , getFileName())
|
||||||
|
.append("mapping" , getMapping())
|
||||||
|
.append("fileAddr" , getFileAddr())
|
||||||
|
.append("fileType" , getFileType())
|
||||||
|
.append("fileSize" , getFileSize())
|
||||||
|
.append("isPublic" , getIsPublic())
|
||||||
|
.append("createBy" , getCreateBy())
|
||||||
|
.append("createTime" , getCreateTime())
|
||||||
|
.append("updateBy" , getUpdateBy())
|
||||||
|
.append("updateTime" , getUpdateTime())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
package com.hchyun.system.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.hchyun.common.utils.ServerResult;
|
||||||
|
import com.hchyun.system.entity.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件信息Service接口
|
||||||
|
*
|
||||||
|
* @author hchyun
|
||||||
|
* @date 2021-02-17
|
||||||
|
*/
|
||||||
|
public interface FileService {
|
||||||
|
/**
|
||||||
|
* 查询文件信息
|
||||||
|
*
|
||||||
|
* @param fileId 文件信息ID
|
||||||
|
* @return 文件信息
|
||||||
|
*/
|
||||||
|
ServerResult<File> selectFileById(Long fileId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询文件信息列表
|
||||||
|
*
|
||||||
|
* @param file 文件信息
|
||||||
|
* @return 文件信息集合
|
||||||
|
*/
|
||||||
|
ServerResult<List<File>> selectFileList(File file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增文件信息
|
||||||
|
*
|
||||||
|
* @param file 文件信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
ServerResult<Integer> insertFile(File file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改文件信息
|
||||||
|
*
|
||||||
|
* @param file 文件信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
ServerResult<Integer> updateFile(File file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除文件信息
|
||||||
|
*
|
||||||
|
* @param fileIds 需要删除的文件信息ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
ServerResult<Integer> deleteFileByIds(Long[] fileIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文件信息信息
|
||||||
|
*
|
||||||
|
* @param fileId 文件信息ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
ServerResult<Integer> deleteFileById(Long fileId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -31,8 +31,9 @@ public interface ISysRoleService
|
||||||
* 查询所有角色
|
* 查询所有角色
|
||||||
*
|
*
|
||||||
* @return 角色列表
|
* @return 角色列表
|
||||||
|
* @param type
|
||||||
*/
|
*/
|
||||||
public List<SysRole> selectRoleAll();
|
public List<SysRole> selectRoleAll(Integer type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户ID获取角色选择框列表
|
* 根据用户ID获取角色选择框列表
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,161 @@
|
||||||
|
package com.hchyun.system.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.hchyun.common.constant.ReturnConstants;
|
||||||
|
import com.hchyun.common.utils.SecurityUtils;
|
||||||
|
import com.hchyun.common.utils.DateUtils;
|
||||||
|
import com.hchyun.common.utils.SecurityUtils;
|
||||||
|
import com.hchyun.common.utils.DateUtils;
|
||||||
|
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.system.dao.FileDao;
|
||||||
|
import com.hchyun.system.entity.File;
|
||||||
|
import com.hchyun.system.service.FileService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件信息Service业务层处理
|
||||||
|
*
|
||||||
|
* @author hchyun
|
||||||
|
* @date 2021-02-17
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class FileServiceImpl implements FileService {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(FileServiceImpl.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FileDao fileDao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询文件信息
|
||||||
|
*
|
||||||
|
* @param fileId 文件信息ID
|
||||||
|
* @return 文件信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ServerResult<File> selectFileById(Long fileId) {
|
||||||
|
try {
|
||||||
|
File file = fileDao.selectFileById(fileId);
|
||||||
|
if (file != null){
|
||||||
|
return new ServerResult<File>(true,file);
|
||||||
|
}else {
|
||||||
|
return new ServerResult<File>(false, ReturnConstants.RESULT_EMPTY);
|
||||||
|
}
|
||||||
|
}catch (RuntimeException e){
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return new ServerResult<File>(false,ReturnConstants.DB_EX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询文件信息列表
|
||||||
|
*
|
||||||
|
* @param file 文件信息
|
||||||
|
* @return 文件信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ServerResult<List<File>> selectFileList(File file) {
|
||||||
|
try {
|
||||||
|
List<File> fileList = fileDao.selectFileList(file);
|
||||||
|
if (fileList.size()>0){
|
||||||
|
return new ServerResult<List<File>>(true,fileList);
|
||||||
|
}else {
|
||||||
|
return new ServerResult<List<File>>(false,ReturnConstants.RESULT_EMPTY);
|
||||||
|
}
|
||||||
|
}catch (RuntimeException e){
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return new ServerResult<List<File>>(false,ReturnConstants.DB_EX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增文件信息
|
||||||
|
*
|
||||||
|
* @param file 文件信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ServerResult<Integer> insertFile(File file) {
|
||||||
|
try {
|
||||||
|
file.setCreateBy(SecurityUtils.getUserId());
|
||||||
|
Integer renewal = fileDao.insertFile(file);
|
||||||
|
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 file 文件信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ServerResult<Integer> updateFile(File file) {
|
||||||
|
try {
|
||||||
|
file.setUpdateBy(SecurityUtils.getUserId());
|
||||||
|
Integer renewal = fileDao.updateFile(file);
|
||||||
|
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 fileIds 需要删除的文件信息ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ServerResult<Integer> deleteFileByIds(Long[] fileIds) {
|
||||||
|
try {
|
||||||
|
Integer renewal = fileDao.deleteFileByIds(fileIds);
|
||||||
|
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 fileId 文件信息ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ServerResult<Integer> deleteFileById(Long fileId) {
|
||||||
|
try {
|
||||||
|
Integer renewal = fileDao.deleteFileById(fileId);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -80,11 +80,12 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||||
* 查询所有角色
|
* 查询所有角色
|
||||||
*
|
*
|
||||||
* @return 角色列表
|
* @return 角色列表
|
||||||
|
* @param type
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SysRole> selectRoleAll()
|
public List<SysRole> selectRoleAll(Integer type)
|
||||||
{
|
{
|
||||||
return SpringUtils.getAopProxy(this).selectRoleList(new SysRole());
|
return SpringUtils.getAopProxy(this).selectRoleList(new SysRole(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
<?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.system.dao.FileDao">
|
||||||
|
|
||||||
|
<resultMap type="com.hchyun.system.entity.File" id="FileResult">
|
||||||
|
<result property="fileId" column="file_id" />
|
||||||
|
<result property="pId" column="p_id" />
|
||||||
|
<result property="roleIds" column="role_ids" />
|
||||||
|
<result property="fileName" column="file_name" />
|
||||||
|
<result property="mapping" column="mapping" />
|
||||||
|
<result property="fileAddr" column="file_addr" />
|
||||||
|
<result property="fileType" column="file_type" />
|
||||||
|
<result property="fileSize" column="file_size" />
|
||||||
|
<result property="isPublic" column="is_public" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectFileVo">
|
||||||
|
select file_id, p_id, role_ids, file_name, mapping, file_addr, file_type, file_size, is_public, create_by, create_time, update_by, update_time from sys_file
|
||||||
|
</sql>
|
||||||
|
<select id="selectFileList" parameterType="File" resultMap="FileResult">
|
||||||
|
<include refid="selectFileVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="fileName != null and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
|
||||||
|
<if test="fileAddr != null and fileAddr != ''"> and file_addr like concat('%', #{fileAddr}, '%')</if>
|
||||||
|
<if test="fileType != null and fileType != ''"> and file_type = #{fileType}</if>
|
||||||
|
<if test="isPublic != null and isPublic != ''"> and is_public = #{isPublic}</if>
|
||||||
|
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectFileById" parameterType="Long" resultMap="FileResult">
|
||||||
|
<include refid="selectFileVo"/>
|
||||||
|
where file_id = #{fileId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<insert id="insertFile" parameterType="File" useGeneratedKeys="true" keyProperty="fileId">
|
||||||
|
insert into sys_file
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="pId != null">p_id,</if>
|
||||||
|
<if test="roleIds != null">role_ids,</if>
|
||||||
|
<if test="fileName != null">file_name,</if>
|
||||||
|
<if test="mapping != null">mapping,</if>
|
||||||
|
<if test="fileAddr != null">file_addr,</if>
|
||||||
|
<if test="fileType != null">file_type,</if>
|
||||||
|
<if test="fileSize != null">file_size,</if>
|
||||||
|
<if test="isPublic != null">is_public,</if>
|
||||||
|
<if test="createBy != null">create_by,</if>
|
||||||
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="pId != null">#{pId},</if>
|
||||||
|
<if test="roleIds != null">#{roleIds},</if>
|
||||||
|
<if test="fileName != null">#{fileName},</if>
|
||||||
|
<if test="mapping != null">#{mapping},</if>
|
||||||
|
<if test="fileAddr != null">#{fileAddr},</if>
|
||||||
|
<if test="fileType != null">#{fileType},</if>
|
||||||
|
<if test="fileSize != null">#{fileSize},</if>
|
||||||
|
<if test="isPublic != null">#{isPublic},</if>
|
||||||
|
<if test="createBy != null">#{createBy},</if>
|
||||||
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateFile" parameterType="File">
|
||||||
|
update sys_file
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="pId != null">p_id = #{pId},</if>
|
||||||
|
<if test="roleIds != null">role_ids = #{roleIds},</if>
|
||||||
|
<if test="isPublic != null">is_public = #{isPublic},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
</trim>
|
||||||
|
where file_id = #{fileId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteFileById" parameterType="Long">
|
||||||
|
delete from sys_file where file_id = #{fileId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteFileByIds" parameterType="String">
|
||||||
|
delete from sys_file where file_id in
|
||||||
|
<foreach item="fileId" collection="array" open="(" separator="," close=")">
|
||||||
|
#{fileId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
@ -19,11 +19,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by" />
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time" />
|
||||||
<result property="remark" column="remark" />
|
<result property="remark" column="remark" />
|
||||||
|
<result property="roleType" column="role_type" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectRoleVo">
|
<sql id="selectRoleVo">
|
||||||
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
|
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
|
||||||
r.status, r.del_flag, r.create_time, r.remark
|
r.status, r.del_flag, r.create_time, r.remark ,r.role_type
|
||||||
from sys_role r
|
from sys_role r
|
||||||
left join sys_user_role ur on ur.role_id = r.role_id
|
left join sys_user_role ur on ur.role_id = r.role_id
|
||||||
left join sys_user u on u.user_id = ur.user_id
|
left join sys_user u on u.user_id = ur.user_id
|
||||||
|
|
@ -33,6 +34,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<select id="selectRoleList" parameterType="SysRole" resultMap="SysRoleResult">
|
<select id="selectRoleList" parameterType="SysRole" resultMap="SysRoleResult">
|
||||||
<include refid="selectRoleVo"/>
|
<include refid="selectRoleVo"/>
|
||||||
where r.del_flag = '0'
|
where r.del_flag = '0'
|
||||||
|
<if test="roleType != 0">
|
||||||
|
and r.role_type = #{roleType}
|
||||||
|
</if>
|
||||||
<if test="roleName != null and roleName != ''">
|
<if test="roleName != null and roleName != ''">
|
||||||
AND r.role_name like concat('%', #{roleName}, '%')
|
AND r.role_name like concat('%', #{roleName}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue