# Conflicts:
#	springbootpt9c5/src/main/java/com/annotation/APPLoginUser.java
#	springbootpt9c5/src/main/java/com/annotation/IgnoreAuth.java
#	springbootpt9c5/src/main/java/com/annotation/LoginUser.java
#	springbootpt9c5/src/main/java/com/config/InterceptorConfig.java
#	springbootpt9c5/src/main/java/com/controller/CommonController.java
#	springbootpt9c5/src/main/java/com/controller/ConfigController.java
branch2
admin 4 months ago
commit 72f161bc19

@ -1,31 +1,31 @@
<template>
<svg :class="svgClass" aria-hidden="true" v-on="$listeners">
<use :xlink:href="iconName" />
<svg :class="svgClass" aria-hidden="true" v-on="$listeners"> <!-- SVG -->
<use :xlink:href="iconName" /> <!-- 使用图标符号 -->
</svg>
</template>
<script>
export default {
name: 'SvgIcon',
name: 'SvgIcon', <!-- 组件名称 -->
props: {
iconClass: {
iconClass: { <!-- 图标类名 -->
type: String,
required: true
required: true <!-- 必须传递 -->
},
className: {
className: { <!-- 自定义类名 -->
type: String,
default: ''
default: '' <!-- 默认为空 -->
}
},
computed: {
iconName() {
return `#icon-${this.iconClass}`
iconName() { <!-- 计算图标符号名称 -->
return `#icon-${this.iconClass}`; <!-- 动态生成图标符号 -->
},
svgClass() {
if (this.className) {
return 'svg-icon ' + this.className
svgClass() { <!-- 计算SVG类名 -->
if (this.className) { <!-- 如果有自定义类名 -->
return 'svg-icon ' + this.className; <!-- 返回组合类名 -->
} else {
return 'svg-icon'
return 'svg-icon'; <!-- 否则返回默认类名 -->
}
}
}
@ -33,11 +33,11 @@ export default {
</script>
<style scoped>
.svg-icon {
width: 1em;
height: 1em;
vertical-align: -0.15em;
fill: currentColor;
overflow: hidden;
.svg-icon { <!-- SVG图标的基本样式 -->
width: 1em; <!-- 宽度 -->
height: 1em; <!-- 高度 -->
vertical-align: -0.15em; <!-- 垂直对齐 -->
fill: currentColor; <!-- 使用当前文本颜色 -->
overflow: hidden; <!-- 隐藏溢出内容 -->
}
</style>
</style>

@ -1,9 +1,26 @@
<template>
<el-breadcrumb class="app-breadcrumb" separator="/" style="height:43px;backgroundColor:rgba(98, 190, 84, 1);borderRadius:0 160px 0 0 ;padding:0px 20px 0px 20px;boxShadow:0px 0px 0px #f903d4;borderWidth:5px 3px 5px 5px;borderStyle:solid;borderColor:rgba(78, 147, 67, 1);">
<transition-group name="breadcrumb" class="box" :style="1==1?'justifyContent:flex-start;':1==2?'justifyContent:center;':'justifyContent:flex-end;'">
<!-- 导航面包屑组件 -->
<el-breadcrumb class="app-breadcrumb" separator="/"
style="height:43px; backgroundColor:rgba(98, 190, 84, 1); borderRadius:0 160px 0 0; padding:0px 20px 0px 20px; boxShadow:0px 0px 0px #f903d4; borderWidth:5px 3px 5px 5px; borderStyle:solid; borderColor:rgba(78, 147, 67, 1);">
<!-- 动态调整面包屑布局 -->
<transition-group name="breadcrumb" class="box"
:style="1==1 ? 'justifyContent:flex-start;' : 1==2 ? 'justifyContent:center;' : 'justifyContent:flex-end;'">
<!-- 遍历路由路径生成面包屑项 -->
<el-breadcrumb-item v-for="(item,index) in levelList" :key="item.path">
<span v-if="item.redirect==='noRedirect'||index==levelList.length-1" class="no-redirect" style="color:rgba(255, 255, 255, 1)">{{ item.name }}</span>
<a v-else @click.prevent="handleLink(item)">{{ item.name }}</a>
<!-- 如果当前项不可点击或为最后一项则显示文本 -->
<span v-if="item.redirect==='noRedirect'||index==levelList.length-1"
class="no-redirect"
style="color:rgba(255, 255, 255, 1)">
{{ item.name }}
</span>
<!-- 否则显示链接 -->
<a v-else @click.prevent="handleLink(item)">
{{ item.name }}
</a>
</el-breadcrumb-item>
</transition-group>
</el-breadcrumb>
@ -12,81 +29,99 @@
<script>
import pathToRegexp from 'path-to-regexp'
import { generateTitle } from '@/utils/i18n'
export default {
data() {
return {
levelList: null
levelList: null //
}
},
//
watch: {
$route() {
this.getBreadcrumb()
}
},
//
created() {
this.getBreadcrumb()
this.breadcrumbStyleChange()
},
methods: {
// utils/i18n
generateTitle,
//
getBreadcrumb() {
// only show routes with meta.title
let route = this.$route
let matched = route.matched.filter(item => item.meta)
let matched = route.matched.filter(item => item.meta) // meta
const first = matched[0]
matched = [{ path: '/index' }].concat(matched)
matched = [{ path: '/index' }].concat(matched) //
this.levelList = matched.filter(item => item.meta)
this.levelList = matched.filter(item => item.meta) //
},
//
isDashboard(route) {
const name = route && route.name
if (!name) {
return false
}
if (!name) return false
return name.trim().toLocaleLowerCase() === 'Index'.toLocaleLowerCase()
},
//
pathCompile(path) {
// To solve this problem https://github.com/PanJiaChen/vue-element-admin/issues/561
const { params } = this.$route
var toPath = pathToRegexp.compile(path)
return toPath(params)
const toPath = pathToRegexp.compile(path) //
return toPath(params) //
},
//
handleLink(item) {
const { redirect, path } = item
if (redirect) {
this.$router.push(redirect)
this.$router.push(redirect) //
return
}
this.$router.push(path)
this.$router.push(path) //
},
//
breadcrumbStyleChange(val) {
this.$nextTick(()=>{
document.querySelectorAll('.app-breadcrumb .el-breadcrumb__separator').forEach(el=>{
el.innerText = "/"
el.style.color = "rgba(217, 217, 217, 1)"
this.$nextTick(() => {
//
document.querySelectorAll('.app-breadcrumb .el-breadcrumb__separator').forEach(el => {
el.innerText = "/" // 设置分隔符为 "/"
el.style.color = "rgba(217, 217, 217, 1)" //
})
document.querySelectorAll('.app-breadcrumb .el-breadcrumb__inner a').forEach(el=>{
el.style.color = "rgba(255, 255, 255, 1)"
//
document.querySelectorAll('.app-breadcrumb .el-breadcrumb__inner a').forEach(el => {
el.style.color = "rgba(255, 255, 255, 1)" //
})
document.querySelectorAll('.app-breadcrumb .el-breadcrumb__inner .no-redirect').forEach(el=>{
el.style.color = "rgba(255, 255, 255, 1)"
//
document.querySelectorAll('.app-breadcrumb .el-breadcrumb__inner .no-redirect').forEach(el => {
el.style.color = "rgba(255, 255, 255, 1)" //
})
//
let str = "2"
if(2 == str) {
if (2 == str) {
let headHeight = "80px"
headHeight = parseInt(headHeight) + 10 + 'px'
document.querySelectorAll('.app-breadcrumb').forEach(el=>{
el.style.marginTop = headHeight
headHeight = parseInt(headHeight) + 10 + 'px' //
document.querySelectorAll('.app-breadcrumb').forEach(el => {
el.style.marginTop = headHeight //
})
}
})
},
}
}
}
</script>
//
<style lang="scss" scoped>
.app-breadcrumb {
display: block;
@ -97,13 +132,12 @@ export default {
display: flex;
width: 100%;
height: 100%;
justify-content: flex-start;
justify-content: flex-start; /* 默认左对齐 */
align-items: center;
}
.no-redirect {
color: #97a8be;
cursor: text;
color: #97a8be; /* 不可点击项的颜色 */
cursor: text; /* 设置鼠标悬停时为文本光标 */
}
}
</style>
</style>

@ -1,41 +1,47 @@
以下是为您的代码添加详细注释后的版本
<template>
<div>
<!-- 图片上传组件辅助-->
<!-- 图片上传组件辅助 -->
<el-upload
class="avatar-uploader"
:action="getActionUrl"
name="file"
:headers="header"
:show-file-list="false"
:on-success="uploadSuccess"
:on-error="uploadError"
:before-upload="beforeUpload"
></el-upload>
:action="getActionUrl" <!-- 图片上传接口 -->
name="file" <!-- 文件字段名 -->
:headers="header" <!-- 请求头 -->
:show-file-list="false" <!-- 不显示已上传文件列表 -->
:on-success="uploadSuccess" <!-- 上传成功回调 -->
:on-error="uploadError" <!-- 上传失败回调 -->
:before-upload="beforeUpload" <!-- 上传前回调 -->
>
<!-- 隐藏的文件输入框 -->
<input type="file" style="display:none;">
</el-upload>
<!-- 富文本编辑器 -->
<quill-editor
class="editor"
v-model="value"
ref="myQuillEditor"
:options="editorOption"
@blur="onEditorBlur($event)"
@focus="onEditorFocus($event)"
@change="onEditorChange($event)"
v-model="value" <!-- 绑定编辑器内容 -->
ref="myQuillEditor" <!-- 引用编辑器实例 -->
:options="editorOption" <!-- 编辑器配置 -->
@blur="onEditorBlur($event)" <!-- 失去焦点事件 -->
@focus="onEditorFocus($event)" <!-- 获得焦点事件 -->
@change="onEditorChange($event)" <!-- 内容改变事件 -->
></quill-editor>
</div>
</template>
<script>
//
<!-- 工具栏配置 -->
const toolbarOptions = [
["bold", "italic", "underline", "strike"], // 线 线
["blockquote", "code-block"], //
[{ header: 1 }, { header: 2 }], // 12
["bold", "italic", "underline", "strike"], // 线线
["blockquote", "code-block"], //
[{ header: 1 }, { header: 2 }], //
[{ list: "ordered" }, { list: "bullet" }], //
[{ script: "sub" }, { script: "super" }], // /
[{ script: "sub" }, { script: "super" }], //
[{ indent: "-1" }, { indent: "+1" }], //
// [{'direction': 'rtl'}], //
[{ size: ["small", false, "large", "huge"] }], //
[{ header: [1, 2, 3, 4, 5, 6, false] }], //
[{ color: [] }, { background: [] }], //
[{ color: [] }, { background: [] }], //
[{ font: [] }], //
[{ align: [] }], //
["clean"], //
@ -43,23 +49,23 @@ const toolbarOptions = [
];
import { quillEditor } from "vue-quill-editor";
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
import "quill/dist/quill.core.css"; //
import "quill/dist/quill.snow.css"; //
import "quill/dist/quill.bubble.css"; //
export default {
props: {
/*编辑器的内容*/
/* 编辑器的内容 */
value: {
type: String
},
action: {
type: String
},
/*图片大小*/
/* 图片大小限制 */
maxSize: {
type: Number,
default: 4000 //kb
default: 4000 // kb
}
},
@ -69,19 +75,18 @@ export default {
data() {
return {
content: this.value,
quillUpdateImg: false, // loadingfalse,
content: this.value, //
quillUpdateImg: false, //
editorOption: {
placeholder: "",
theme: "snow", // or 'bubble'
placeholder: "", //
theme: "snow", //
modules: {
toolbar: {
container: toolbarOptions,
// container: "#toolbar",
container: toolbarOptions, //
handlers: {
image: function(value) {
if (value) {
// input
//
document.querySelector(".avatar-uploader input").click();
} else {
this.quill.format("image", false);
@ -99,142 +104,136 @@ export default {
}
}
},
// serverUrl: `${base.url}sys/storage/uploadSwiper?token=${storage.get('token')}`, //
header: {
// token: sessionStorage.token
'Token': this.$storage.get("Token")
} // token
'Token': this.$storage.get("Token") // Token
}
};
},
computed: {
// getter
// URL
getActionUrl: function() {
// return this.$base.url + this.action + "?token=" + this.$storage.get("token");
return `/${this.$base.name}/` + this.action;
}
},
methods: {
onEditorBlur() {
//
//
},
onEditorFocus() {
//
//
},
onEditorChange() {
console.log(this.value);
//
//
this.$emit("input", this.value);
},
//
beforeUpload() {
// loading
beforeUpload(file) {
//
this.quillUpdateImg = true;
const isLtMaxSize = file.size / 1024 < this.maxSize; //
if (!isLtMaxSize) {
this.$message.error(`上传图片大小不能超过 ${this.maxSize} KB!`);
}
return isLtMaxSize;
},
uploadSuccess(res, file) {
// res
//
let quill = this.$refs.myQuillEditor.quill;
//
//
let quill = this.$refs.myQuillEditor.quill; //
if (res.code === 0) {
//
let length = quill.getSelection().index;
// res.url
quill.insertEmbed(length, "image", this.$base.url+ "upload/" +res.file);
//
quill.setSelection(length + 1);
let length = quill.getSelection().index; //
quill.insertEmbed(length, "image", this.$base.url + "upload/" + res.file); //
quill.setSelection(length + 1); //
} else {
this.$message.error("图片插入失败");
}
// loading
this.quillUpdateImg = false;
this.quillUpdateImg = false; //
},
//
uploadError() {
// loading
this.quillUpdateImg = false;
//
this.quillUpdateImg = false; //
this.$message.error("图片插入失败");
}
}
};
</script>
/* 样式部分 */
<style>
.editor {
line-height: normal !important;
line-height: normal !important; /* 设置行高 */
}
.ql-snow .ql-tooltip[data-mode="link"]::before {
content: "请输入链接地址:";
content: "请输入链接地址:"; /* 自定义链接提示 */
}
.ql-snow .ql-tooltip.ql-editing a.ql-action::after {
border-right: 0px;
border-right: 0px; /* 修改链接编辑按钮样式 */
content: "保存";
padding-right: 0px;
}
.ql-snow .ql-tooltip[data-mode="video"]::before {
content: "请输入视频地址:";
content: "请输入视频地址:"; /* 自定义视频提示 */
}
.ql-container {
height: 400px;
height: 400px; /* 设置富文本高度 */
}
.ql-snow .ql-picker.ql-size .ql-picker-label::before,
.ql-snow .ql-picker.ql-size .ql-picker-item::before {
content: "14px";
content: "14px"; /* 设置默认字体大小 */
}
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="small"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="small"]::before {
content: "10px";
content: "10px"; /* 设置小字体 */
}
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="large"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="large"]::before {
content: "18px";
content: "18px"; /* 设置大字体 */
}
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="huge"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="huge"]::before {
content: "32px";
content: "32px"; /* 设置超大字体 */
}
.ql-snow .ql-picker.ql-header .ql-picker-label::before,
.ql-snow .ql-picker.ql-header .ql-picker-item::before {
content: "文本";
content: "文本"; /* 设置默认标题 */
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="1"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="1"]::before {
content: "标题1";
content: "标题1"; /* 设置标题1 */
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="2"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="2"]::before {
content: "标题2";
content: "标题2"; /* 设置标题2 */
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="3"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="3"]::before {
content: "标题3";
content: "标题3"; /* 设置标题3 */
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="4"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="4"]::before {
content: "标题4";
content: "标题4"; /* 设置标题4 */
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="5"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="5"]::before {
content: "标题5";
content: "标题5"; /* 设置标题5 */
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="6"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="6"]::before {
content: "标题6";
content: "标题6"; /* 设置标题6 */
}
.ql-snow .ql-picker.ql-font .ql-picker-label::before,
.ql-snow .ql-picker.ql-font .ql-picker-item::before {
content: "标准字体";
content: "标准字体"; /* 设置默认字体 */
}
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="serif"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="serif"]::before {
content: "衬线字体";
content: "衬线字体"; /* 设置衬线字体 */
}
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="monospace"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="monospace"]::before {
content: "等宽字体";
content: "等宽字体"; /* 设置等宽字体 */
}
</style>

@ -1,142 +1,146 @@
<template>
<div>
<!-- 上传文件组件 -->
<!-- 文件上传组件 -->
<el-upload
ref="upload"
:action="getActionUrl"
list-type="picture-card"
accept=".xls,.xlsx"
:limit="limit"
:headers="myHeaders"
:file-list="fileList"
:on-exceed="handleExceed"
:on-preview="handleUploadPreview"
:on-remove="handleRemove"
:on-success="handleUploadSuccess"
:on-error="handleUploadErr"
:before-upload="handleBeforeUpload"
ref="upload" <!-- 引用上传组件实例 -->
:action="getActionUrl" <!-- 上传接口地址 -->
list-type="picture-card" <!-- 列表类型 -->
accept=".xls,.xlsx" <!-- 仅允许上传 Excel 文件 -->
:limit="limit" <!-- 最大上传数量 -->
:headers="myHeaders" <!-- 请求头 -->
:file-list="fileList" <!-- 绑定上传文件列表 -->
:on-exceed="handleExceed" <!-- 超出限制时触发 -->
:on-preview="handleUploadPreview" <!-- 点击预览时触发 -->
:on-remove="handleRemove" <!-- 删除文件时触发 -->
:on-success="handleUploadSuccess" <!-- 上传成功时触发 -->
:on-error="handleUploadErr" <!-- 上传失败时触发 -->
:before-upload="handleBeforeUpload" <!-- 上传前触发 -->
>
<i class="el-icon-plus"></i>
<div slot="tip" class="el-upload__tip" style="color:#838fa1;">{{tip}}</div>
<i class="el-icon-plus"></i> <!-- 默认显示的加号图标 -->
<div slot="tip" class="el-upload__tip" style="color:#838fa1;">{{tip}}</div> <!-- 提示文字 -->
</el-upload>
<!-- 查看大图弹窗 -->
<el-dialog :visible.sync="dialogVisible" size="tiny" append-to-body>
<img width="100%" :src="dialogImageUrl" alt>
<img width="100%" :src="dialogImageUrl" alt> <!-- 展示图片 -->
</el-dialog>
</div>
</template>
<script>
import storage from "@/utils/storage";
import base from "@/utils/base";
import storage from "@/utils/storage"; //
import base from "@/utils/base"; //
export default {
data() {
return {
//
dialogVisible: false,
//
dialogImageUrl: "",
//
fileList: [],
fileUrlList: [],
myHeaders:{}
dialogVisible: false, //
dialogImageUrl: "", //
fileList: [], //
fileUrlList: [], // URL
myHeaders: {} //
};
},
props: ["tip", "action", "limit", "multiple", "fileUrls"],
props: {
tip: String, //
action: String, //
limit: Number, //
multiple: Boolean, //
fileUrls: String // URL
},
mounted() {
this.init();
this.myHeaders= {
'Token':storage.get("Token")
}
this.init(); //
this.myHeaders = { //
'Token': storage.get("Token")
};
},
watch: {
fileUrls: function(val, oldVal) {
// console.log("new: %s, old: %s", val, oldVal);
// URL
this.init();
}
},
computed: {
// getter
// URL
getActionUrl: function() {
// return base.url + this.action + "?token=" + storage.get("token");
return `/${this.$base.name}/` + this.action;
}
},
methods: {
//
init() {
// console.log(this.fileUrls);
if (this.fileUrls) {
this.fileUrlList = this.fileUrls.split(",");
let fileArray = [];
this.fileUrlList = this.fileUrls.split(","); //
let fileArray = []; //
this.fileUrlList.forEach(function(item, index) {
var url = item;
var name = index;
var url = item; // URL
var name = index; //
var file = {
name: name,
url: url
};
fileArray.push(file);
}; //
fileArray.push(file); //
});
this.setFileList(fileArray);
this.setFileList(fileArray); //
}
},
handleBeforeUpload(file) {
//
//
},
//
handleUploadSuccess(res, file, fileList) {
if (res && res.code === 0) {
fileList[fileList.length - 1]["url"] = "upload/" + file.response.file;
this.setFileList(fileList);
this.$emit("change", this.fileUrlList.join(","));
this.$message.success("文件导入成功");
if (res && res.code === 0) { //
fileList[fileList.length - 1]["url"] = "upload/" + file.response.file; // URL
this.setFileList(fileList); //
this.$emit("change", this.fileUrlList.join(",")); //
this.$message.success("文件导入成功"); //
} else {
this.$message.error(res.msg);
this.$message.error(res.msg); //
}
},
//
handleUploadErr(err, file, fileList) {
this.$message.error("文件导入失败");
this.$message.error("文件导入失败"); //
},
//
handleRemove(file, fileList) {
this.setFileList(fileList);
this.$emit("change", this.fileUrlList.join(","));
this.setFileList(fileList); //
this.$emit("change", this.fileUrlList.join(",")); //
},
//
handleUploadPreview(file) {
this.dialogImageUrl = file.url;
this.dialogVisible = true;
this.dialogImageUrl = file.url; //
this.dialogVisible = true; //
},
//
handleExceed(files, fileList) {
this.$message.warning(`最多上传${this.limit}张图片`);
this.$message.warning(`最多上传${this.limit}张图片`); //
},
// fileList
setFileList(fileList) {
var fileArray = [];
var fileUrlArray = [];
// token
var token = storage.get("token");
let _this = this;
var fileArray = []; //
var fileUrlArray = []; // URL
var token = storage.get("Token"); // Token
let _this = this; //
fileList.forEach(function(item, index) {
var url = item.url.split("?")[0];
if(!url.startsWith("http")) {
url = _this.$base.url+url
}
var name = item.name;
var file = {
var url = item.url.split("?")[0]; // URL
if (!url.startsWith("http")) { // URL http
url = _this.$base.url + url;
}
var name = item.name; //
var file = { //
name: name,
url: url + "?token=" + token
url: url + "?token=" + token // Token
};
fileArray.push(file);
fileUrlArray.push(url);
fileArray.push(file); //
fileUrlArray.push(url); // URL
});
this.fileList = fileArray;
this.fileUrlList = fileUrlArray;
this.fileList = fileArray; //
this.fileUrlList = fileUrlArray; // URL
}
}
};
</script>
<style lang="scss" scoped>
</style>
<style lang="scss" scoped>
</style>

@ -1,140 +1,145 @@
<template>
<div>
<!-- 上传文件组件 -->
<!-- 文件上传组件 -->
<el-upload
ref="upload"
:action="getActionUrl"
list-type="picture-card"
:multiple="multiple"
:limit="limit"
:headers="myHeaders"
:file-list="fileList"
:on-exceed="handleExceed"
:on-preview="handleUploadPreview"
:on-remove="handleRemove"
:on-success="handleUploadSuccess"
:on-error="handleUploadErr"
:before-upload="handleBeforeUpload"
ref="upload" <!-- 引用上传组件实例 -->
:action="getActionUrl" <!-- 上传接口地址 -->
list-type="picture-card" <!-- 列表类型 -->
:multiple="multiple" <!-- 是否支持多选 -->
:limit="limit" <!-- 最大上传数量 -->
:headers="myHeaders" <!-- 请求头 -->
:file-list="fileList" <!-- 绑定上传文件列表 -->
:on-exceed="handleExceed" <!-- 超出限制时触发 -->
:on-preview="handleUploadPreview" <!-- 点击预览时触发 -->
:on-remove="handleRemove" <!-- 删除文件时触发 -->
:on-success="handleUploadSuccess" <!-- 上传成功时触发 -->
:on-error="handleUploadErr" <!-- 上传失败时触发 -->
:before-upload="handleBeforeUpload" <!-- 上传前触发 -->
>
<i class="el-icon-plus"></i>
<div slot="tip" class="el-upload__tip" style="color:#838fa1;">{{tip}}</div>
<i class="el-icon-plus"></i> <!-- 默认显示的加号图标 -->
<div slot="tip" class="el-upload__tip" style="color:#838fa1;">{{tip}}</div> <!-- 提示文字 -->
</el-upload>
<!-- 查看大图弹窗 -->
<el-dialog :visible.sync="dialogVisible" size="tiny" append-to-body>
<img width="100%" :src="dialogImageUrl" alt>
<img width="100%" :src="dialogImageUrl" alt> <!-- 展示图片 -->
</el-dialog>
</div>
</template>
<script>
import storage from "@/utils/storage";
import base from "@/utils/base";
import storage from "@/utils/storage"; //
import base from "@/utils/base"; //
export default {
data() {
return {
//
dialogVisible: false,
//
dialogImageUrl: "",
//
fileList: [],
fileUrlList: [],
myHeaders:{}
dialogVisible: false, //
dialogImageUrl: "", //
fileList: [], //
fileUrlList: [], // URL
myHeaders: {} //
};
},
props: ["tip", "action", "limit", "multiple", "fileUrls"],
props: {
tip: String, //
action: String, //
limit: Number, //
multiple: Boolean, //
fileUrls: String // URL
},
mounted() {
this.init();
this.myHeaders= {
'Token':storage.get("Token")
}
this.init(); //
this.myHeaders = { //
'Token': storage.get("Token")
};
},
watch: {
fileUrls: function(val, oldVal) {
// console.log("new: %s, old: %s", val, oldVal);
// URL
this.init();
}
},
computed: {
// getter
// URL
getActionUrl: function() {
// return base.url + this.action + "?token=" + storage.get("token");
return `/${this.$base.name}/` + this.action;
}
},
methods: {
//
init() {
// console.log(this.fileUrls);
if (this.fileUrls) {
this.fileUrlList = this.fileUrls.split(",");
let fileArray = [];
this.fileUrlList = this.fileUrls.split(","); //
let fileArray = []; //
this.fileUrlList.forEach(function(item, index) {
var url = item;
var name = index;
var url = item; // URL
var name = index; //
var file = {
name: name,
url: url
};
fileArray.push(file);
}; //
fileArray.push(file); //
});
this.setFileList(fileArray);
this.setFileList(fileArray); //
}
},
handleBeforeUpload(file) {
//
//
},
//
handleUploadSuccess(res, file, fileList) {
if (res && res.code === 0) {
fileList[fileList.length - 1]["url"] = "upload/" + file.response.file;
this.setFileList(fileList);
this.$emit("change", this.fileUrlList.join(","));
if (res && res.code === 0) { //
fileList[fileList.length - 1]["url"] = "upload/" + file.response.file; // URL
this.setFileList(fileList); //
this.$emit("change", this.fileUrlList.join(",")); //
} else {
this.$message.error(res.msg);
this.$message.error(res.msg); //
}
},
//
handleUploadErr(err, file, fileList) {
this.$message.error("文件上传失败");
this.$message.error("文件上传失败"); //
},
//
handleRemove(file, fileList) {
this.setFileList(fileList);
this.$emit("change", this.fileUrlList.join(","));
this.setFileList(fileList); //
this.$emit("change", this.fileUrlList.join(",")); //
},
//
handleUploadPreview(file) {
this.dialogImageUrl = file.url;
this.dialogVisible = true;
this.dialogImageUrl = file.url; //
this.dialogVisible = true; //
},
//
handleExceed(files, fileList) {
this.$message.warning(`最多上传${this.limit}张图片`);
this.$message.warning(`最多上传${this.limit}张图片`); //
},
// fileList
setFileList(fileList) {
var fileArray = [];
var fileUrlArray = [];
// token
var token = storage.get("token");
let _this = this;
var fileArray = []; //
var fileUrlArray = []; // URL
var token = storage.get("Token"); // Token
let _this = this; //
fileList.forEach(function(item, index) {
var url = item.url.split("?")[0];
if(!url.startsWith("http")) {
url = _this.$base.url+url
}
var name = item.name;
var file = {
var url = item.url.split("?")[0]; // URL
if (!url.startsWith("http")) { // URL http
url = _this.$base.url + url;
}
var name = item.name; //
var file = { //
name: name,
url: url + "?token=" + token
url: url + "?token=" + token // Token
};
fileArray.push(file);
fileUrlArray.push(url);
fileArray.push(file); //
fileUrlArray.push(url); // URL
});
this.fileList = fileArray;
this.fileUrlList = fileUrlArray;
this.fileList = fileArray; //
this.fileUrlList = fileUrlArray; // URL
}
}
};
</script>
<style lang="scss" scoped>
</style>
</style>

@ -1,60 +1,72 @@
<template>
<el-card class="box-card">
<!-- 卡片头部 -->
<div slot="header" class="header">
<!-- 标题 -->
<span>{{title}}</span>
<!-- 标签 -->
<span>
<el-tag size="small" :type="titleTag">{{titleUnit}}</el-tag>
</span>
</div>
<!-- 主体内容 -->
<div class="content">
<!-- 主要内容 -->
{{content}}&nbsp;&nbsp;
<!-- 单位 -->
<span class="unit">{{contentUnit}}</span>
</div>
<!-- 底部信息 -->
<div class="bottom">
<!-- 左侧标题 -->
<span>{{bottomTitle}}</span>
<!-- 右侧内容 -->
<span>
{{bottomContent}}
<!-- 图标 -->
<i :class="bottomIcon"></i>
</span>
</div>
</el-card>
</template>
<script>
export default {
props: [
"title",
"titleTag",
"titleUnit",
"content",
"contentUnit",
"bottomTitle",
"bottomContent",
"bottomIcon"
"title", //
"titleTag", //
"titleUnit", //
"content", //
"contentUnit", //
"bottomTitle", //
"bottomContent", //
"bottomIcon" //
]
};
</script>
<style lang="scss" scoped>
.box-card {
margin-right: 10px;
margin-right: 10px; //
.header {
display: flex;
justify-content: space-between;
align-items: center;
display: flex; // 使
justify-content: space-between; //
align-items: center; //
}
.content {
font-size: 30px;
font-weight: bold;
color: #666;
text-align: center;
font-size: 30px; //
font-weight: bold; //
color: #666; //
text-align: center; //
.unit {
font-size: 16px;
font-size: 16px; //
}
}
.bottom {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 10px;
display: flex; // 使
justify-content: space-between; //
align-items: center; //
margin-top: 10px; //
}
}
</style>
</style>

@ -1,33 +1,40 @@
<template>
<div class="home-comment">
<!-- 标题 -->
<div class="title">用户留言</div>
<!-- 留言列表 -->
<div class="comment-list">
<div v-for="(item,index) in list" v-bind:key="index" class="comment-item">
<!-- 循环渲染每个留言项 -->
<div v-for="(item, index) in list" :key="index" class="comment-item">
<!-- 用户头像和用户名 -->
<div class="user-content">
<el-image
class="avator"
:src="item.avator"
:src="item.avator" //
></el-image>
<span class="user">{{item.name}}</span>
<span class="user">{{ item.name }}</span> <!-- 显示用户名 -->
</div>
<div class="comment">{{item.content}}</div>
<div class="create-time">{{item.createTime}}</div>
<!-- 留言内容 -->
<div class="comment">{{ item.content }}</div>
<!-- 创建时间 -->
<div class="create-time">{{ item.createTime }}</div>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
list: [
{
name: "MaskLin",
name: "MaskLin", //
avator:
"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg", //
content:
"你以为只要长得漂亮就有男生喜欢?你以为只要有了钱漂亮妹子就自己贴上来了?你以为学霸就能找到好工作?我告诉你吧,这些都是真的!",
createTime: "5月02日 00:00"
"你以为只要长得漂亮就有男生喜欢?你以为只要有了钱漂亮妹子就自己贴上来了?你以为学霸就能找到好工作?我告诉你吧,这些都是真的!", //
createTime: "5月02日 00:00" //
},
{
name: "MaskLin",
@ -53,49 +60,49 @@ export default {
};
}
};
</script>
<style lang="scss" scoped>
.home-comment {
background: #ffffff;
background: #ffffff; //
.title {
font-size: 18px;
color: #666;
font-weight: bold;
padding: 10px;
border-bottom: 1px solid #eeeeee;
font-size: 18px; //
color: #666; //
font-weight: bold; //
padding: 10px; //
border-bottom: 1px solid #eeeeee; //
}
.comment-list {
padding: 10px;
padding: 10px; //
.comment-item {
padding: 10px;
border-bottom: 1px solid #eeeeee;
padding: 10px; //
border-bottom: 1px solid #eeeeee; //
.user-content {
display: flex;
align-items: center;
display: flex; //
align-items: center; //
.user {
font-size: 18px;
color: #666;
font-weight: bold;
line-height: 50px;
margin-left: 10px;
font-size: 18px; //
color: #666; //
font-weight: bold; //
line-height: 50px; //
margin-left: 10px; //
}
.avator {
width: 50px;
height: 50px;
border-radius: 50%;
width: 50px; //
height: 50px; //
border-radius: 50%; //
}
}
.comment {
margin-top: 10px;
font-size: 14px;
color: #888888;
margin-top: 10px; //
font-size: 14px; //
color: #888888; //
}
.create-time {
margin-top: 15px;
font-size: 14px;
color: #888888;
margin-top: 15px; //
font-size: 14px; //
color: #888888; //
}
}
}
}
</style>
</style>

@ -1,55 +1,68 @@
<template>
<div class="home-progress">
<!-- 第一个标题 -->
<div class="title">月访问量</div>
<!-- 提示文字 -->
<div class="tip">同上期增长</div>
<!-- 进度条组件 -->
<el-progress
class="progress"
:text-inside="true"
:stroke-width="24"
:percentage="20"
status="success"
:text-inside="true" //
:stroke-width="24" //
:percentage="20" //
status="success" //
></el-progress>
<!-- 第二个标题 -->
<div class="title">月用户量</div>
<!-- 提示文字 -->
<div class="tip">同上期增长</div>
<!-- 进度条组件 -->
<el-progress
class="progress"
:text-inside="true"
:stroke-width="24"
:percentage="50"
status="success"
:percentage="50" //
status="success" //
></el-progress>
<!-- 第三个标题 -->
<div class="title">月收入</div>
<!-- 提示文字 -->
<div class="tip">同上期减少</div>
<!-- 进度条组件 -->
<el-progress
class="progress"
:text-inside="true"
:stroke-width="24"
:percentage="28"
status="exception"
:percentage="28" //
status="exception" //
></el-progress>
</div>
</template>
<script>
export default {};
</script>
<style lang="scss">
.home-progress {
background: #ffffff;
height: 400px;
padding: 20px;
background: #ffffff; //
height: 400px; //
padding: 20px; //
.title {
color: #666666;
font-weight: bold;
font-size: 20px;
margin-top: 10px;
color: #666666; //
font-weight: bold; //
font-size: 20px; //
margin-top: 10px; //
}
.tip {
color: #888888;
font-size: 16px;
margin-top: 10px;
color: #888888; //
font-size: 16px; //
margin-top: 10px; //
}
.progress {
margin-top: 10px;
margin-top: 10px; //
}
}
</style>
</style>

@ -1,26 +1,65 @@
<template>
<el-aside class="index-aside" width="200px">
<div class="index-aside-inner menulist">
<div v-for="item in menuList" :key="item.roleName" v-if="role==item.roleName" class="menulist-item">
<!-- 动态渲染菜单 -->
<div v-for="item in menuList" :key="item.roleName" v-if="role == item.roleName" class="menulist-item">
<!-- 用户头像 -->
<div class="menulistImg" v-if="false && 2 == 2">
<el-image :style='{"padding":"0","boxShadow":"0 0 6px rgba(0,0,0,0)","margin":"0","borderColor":"rgba(0,0,0,0)","borderRadius":"0","borderWidth":"0","width":"100%","borderStyle":"solid","height":"auto"}' v-if="'http://codegen.caihongy.cn/20201021/cc7d45d9c8164b58b18351764eba9be1.jpg'" src="http://codegen.caihongy.cn/20201021/cc7d45d9c8164b58b18351764eba9be1.jpg" fit="cover" />
<el-image
:style='{
padding: "0",
boxShadow: "0 0 6px rgba(0,0,0,0)",
margin: "0",
borderColor: "rgba(0,0,0,0)",
borderRadius: "0",
borderWidth: "0",
width: "100%",
borderStyle: "solid",
height: "auto"
}'
v-if="'http://codegen.caihongy.cn/20201021/cc7d45d9c8164b58b18351764eba9be1.jpg'"
src="http://codegen.caihongy.cn/20201021/cc7d45d9c8164b58b18351764eba9be1.jpg"
fit="cover"
/>
</div>
<el-menu :mode="2 == 1? 'horizontal':'vertical'" :unique-opened="true" class="el-menu-demo" default-active="0">
<el-menu-item index="0" @click="menuHandler('')"><i v-if="false" class="el-icon-menu el-icon-s-home" />首页</el-menu-item>
<el-submenu :index="1+''">
<!-- 主菜单 -->
<el-menu
:mode="2 == 1 ? 'horizontal' : 'vertical'"
:unique-opened="true"
class="el-menu-demo"
default-active="0"
>
<!-- 首页菜单项 -->
<el-menu-item index="0" @click="menuHandler('')">
<i v-if="false" class="el-icon-menu el-icon-s-home" />
首页
</el-menu-item>
<!-- 个人中心子菜单 -->
<el-submenu :index="1 + ''">
<template slot="title">
<i v-if="false" class="el-icon-menu el-icon-user-solid" />
<span>个人中心</span>
<i v-if="false" class="el-icon-menu el-icon-user-solid" />
<span>个人中心</span>
</template>
<el-menu-item :index="1-1" @click="menuHandler('updatePassword')"></el-menu-item>
<el-menu-item :index="1-2" @click="menuHandler('center')"></el-menu-item>
<el-menu-item :index="1 - 1" @click="menuHandler('updatePassword')"></el-menu-item>
<el-menu-item :index="1 - 2" @click="menuHandler('center')"></el-menu-item>
</el-submenu>
<el-submenu v-for=" (menu,index) in item.backMenu" :key="menu.menu" :index="index+2+''">
<!-- 动态渲染子菜单 -->
<el-submenu v-for="(menu, index) in item.backMenu" :key="menu.menu" :index="index + 2 + ''">
<template slot="title">
<i v-if="false" class="el-icon-menu" :class="icons[index]" />
<span>{{ menu.menu }}</span>
<i v-if="false" class="el-icon-menu" :class="icons[index]" />
<span>{{ menu.menu }}</span>
</template>
<el-menu-item v-for=" (child,sort) in menu.child" :key="sort" :index="(index+2)+'-'+sort" @click="menuHandler(child.tableName)">{{ child.menu }}</el-menu-item>
<el-menu-item
v-for="(child, sort) in menu.child"
:key="sort"
:index="(index + 2) + '-' + sort"
@click="menuHandler(child.tableName)"
>
{{ child.menu }}
</el-menu-item>
</el-submenu>
</el-menu>
</div>
@ -30,12 +69,13 @@
<script>
import menu from '@/utils/menu'
export default {
data() {
return {
menuList: [],
dynamicMenuRoutes: [],
role: '',
menuList: [], //
dynamicMenuRoutes: [], //
role: '', //
icons: [
'el-icon-s-cooperation',
'el-icon-s-order',
@ -78,146 +118,144 @@ export default {
'el-icon-stopwatch',
],
menulistStyle: '${template.back.menulist.menulistStyle}',
menulistBorderBottom: {},
menulistBorderBottom: {}, //
}
},
mounted() {
//
const menus = menu.list()
if(menus) {
this.menuList = menus
if (menus) {
this.menuList = menus
} else {
let params = {
page: 1,
limit: 1,
sort: 'id',
let params = {
page: 1,
limit: 1,
sort: 'id',
}
this.$http({
url: "menu/list",
method: "get",
params: params
}).then(({ data }) => {
if (data && data.code === 0) {
this.menuList = JSON.parse(data.data.list[0].menujson)
this.$storage.set("menus", this.menuList)
}
this.$http({
url: "menu/list",
method: "get",
params: params
}).then(({
data
}) => {
if (data && data.code === 0) {
this.menuList = JSON.parse(data.data.list[0].menujson);
this.$storage.set("menus", this.menuList);
}
})
})
}
//
this.role = this.$storage.get('role')
},
created(){
setTimeout(()=>{
created() {
//
setTimeout(() => {
this.menulistStyleChange()
},10)
this.icons.sort(()=>{
return (0.5-Math.random())
})
this.lineBorder()
}, 10)
//
this.icons.sort(() => 0.5 - Math.random())
this.lineBorder()
},
methods: {
lineBorder() {
let style = '${template.back.menulist.menulistStyle}'
let w = '${template.back.menulist.menulistLineWidth}'
let s = '${template.back.menulist.menulistLineStyle}'
let c = '${template.back.menulist.menulistLineColor}'
if(style == 'vertical') {
this.menulistBorderBottom = {
borderBottomWidth: w,
borderBottomStyle: s,
borderBottomColor: c
}
} else {
this.menulistBorderBottom = {
borderRightWidth: w,
borderRightStyle: s,
borderRightColor: c
}
}
},
lineBorder() {
let style = '${template.back.menulist.menulistStyle}'
let w = '${template.back.menulist.menulistLineWidth}'
let s = '${template.back.menulist.menulistLineStyle}'
let c = '${template.back.menulist.menulistLineColor}'
if (style == 'vertical') {
this.menulistBorderBottom = {
borderBottomWidth: w,
borderBottomStyle: s,
borderBottomColor: c
}
} else {
this.menulistBorderBottom = {
borderRightWidth: w,
borderRightStyle: s,
borderRightColor: c
}
}
},
menuHandler(name) {
let router = this.$router
name = '/'+name
name = '/' + name
router.push(name)
},
//
setMenulistHoverColor(){
let that = this
return;
this.$nextTick(()=>{
document.querySelectorAll('.menulist .el-menu-item').forEach(el=>{
//
menulistStyleChange() {
this.setMenulistIconColor()
this.setMenulistHoverColor()
this.setMenulistStyleHeightChange()
let str = "2"
if (1 == str) {
this.$nextTick(() => {
document.querySelectorAll('.el-container .el-container').forEach(el => {
el.style.display = "block"
el.style.paddingTop = "80px" // header
})
document.querySelectorAll('.el-aside').forEach(el => {
el.style.width = "100%"
el.style.height = "auto"
el.style.paddingTop = '0'
})
document.querySelectorAll('.index-aside .index-aside-inner').forEach(el => {
el.style.paddingTop = '0'
el.style.width = "100%"
})
})
}
if (2 === str) {
this.$nextTick(() => {
document.querySelectorAll('.index-aside .index-aside-inner').forEach(el => {
el.style.paddingTop = "80px"
})
})
}
},
setMenulistHoverColor() {
return
this.$nextTick(() => {
document.querySelectorAll('.menulist .el-menu-item').forEach(el => {
el.addEventListener("mouseenter", e => {
e.stopPropagation()
el.style.backgroundColor = "${template.back.menulist.menulistHoverColor}"
})
el.addEventListener("mouseleave", e => {
e.stopPropagation()
// el.style.backgroundColor = "${template.back.menulist.menulistBgColor}"
el.style.background = "none"
el.style.backgroundColor = "none"
})
el.addEventListener("focus", e => {
e.stopPropagation()
el.style.backgroundColor = "${template.back.menulist.menulistHoverColor}"
})
})
document.querySelectorAll('.menulist .el-submenu__title').forEach(el=>{
document.querySelectorAll('.menulist .el-submenu__title').forEach(el => {
el.addEventListener("mouseenter", e => {
e.stopPropagation()
el.style.backgroundColor = "${template.back.menulist.menulistHoverColor}"
})
el.addEventListener("mouseleave", e => {
e.stopPropagation()
// el.style.backgroundColor = "${template.back.menulist.menulistBgColor}"
el.style.background = "none"
el.style.backgroundColor = "none"
})
})
})
},
setMenulistIconColor() {
this.$nextTick(()=>{
document.querySelectorAll('.menulist .el-submenu__title .el-submenu__icon-arrow').forEach(el=>{
this.$nextTick(() => {
document.querySelectorAll('.menulist .el-submenu__title .el-submenu__icon-arrow').forEach(el => {
el.style.color = "${template.back.menulist.menulistIconColor}"
})
})
},
menulistStyleChange() {
this.setMenulistIconColor()
this.setMenulistHoverColor()
this.setMenulistStyleHeightChange()
let str = "2"
if(1 == str) {
this.$nextTick(()=>{
document.querySelectorAll('.el-container .el-container').forEach(el=>{
el.style.display = "block"
el.style.paddingTop = "80px" // header
})
document.querySelectorAll('.el-aside').forEach(el=>{
el.style.width = "100%"
el.style.height = "auto"
el.style.paddingTop = '0'
})
document.querySelectorAll('.index-aside .index-aside-inner').forEach(el=>{
el.style.paddingTop = '0'
el.style.width = "100%"
})
})
}
if(2 === str) {
this.$nextTick(()=>{
document.querySelectorAll('.index-aside .index-aside-inner').forEach(el=>{
el.style.paddingTop = "80px"
})
})
}
},
setMenulistStyleHeightChange() {
return;
this.$nextTick(()=>{
document.querySelectorAll('.menulist-item>.el-menu--horizontal>.el-menu-item').forEach(el=>{
return
this.$nextTick(() => {
document.querySelectorAll('.menulist-item>.el-menu--horizontal>.el-menu-item').forEach(el => {
el.style.height = "${template.back.menulist.menulistHeight}"
el.style.lineHeight = "${template.back.menulist.menulistHeight}"
})
document.querySelectorAll('.menulist-item>.el-menu--horizontal>.el-submenu>.el-submenu__title').forEach(el=>{
document.querySelectorAll('.menulist-item>.el-menu--horizontal>.el-submenu>.el-submenu__title').forEach(el => {
el.style.height = "${template.back.menulist.menulistHeight}"
el.style.lineHeight = "${template.back.menulist.menulistHeight}"
})
@ -226,276 +264,281 @@ export default {
}
}
</script>
<style lang="scss" scoped>
.el-container {
display: block;
}
.index-aside {
position: relative;
overflow: hidden;
display: flex;
flex-wrap: wrap;
.el-container {
display: block;
}
.index-aside {
position: relative;
overflow: hidden;
display: flex;
flex-wrap: wrap;
.menulistImg {
font-size: 0;
box-sizing: border-box;
.menulistImg {
font-size: 0;
box-sizing: border-box;
.el-image {
margin: 0 auto;
width: 100px;
height: 100px;
border-radius: 100%;
display: block;
.el-image {
margin: 0 auto;
width: 100px;
height: 100px;
border-radius: 100%;
display: block;
}
}
.index-aside-inner {
height: 100%;
margin-right: -17px;
margin-bottom: -17px;
overflow: scroll;
overflow-x: hidden !important;
padding-top: 80px;
box-sizing: border-box;
&:focus {
outline: none;
}
& /deep/ .el-menu {
border: 0;
background-color: transparent;
}
}
.index-aside .index-aside-inner.menulist {
height: auto !important;
}
.menulist-item {
width: 200px;
padding: 15px 20px;
margin: 0;
border-radius: 0;
border-width: 0 !important;
border-style: solid !important;
border-color: rgba(254, 236, 190, 1) !important;
background: #FEECBE !important;
box-shadow: 0 0 6px rgba(30, 144, 255, 0.2);
box-sizing: border-box;
}
.el-menu-demo {
box-sizing: border-box;
min-height: calc(100vh - 80px);
& > .el-menu-item {
width: auto;
height: auto !important;
line-height: 24px !important;
padding: 10px 22px 10px 10px;
margin: 0 0 10px 0;
color: rgba(255, 255, 255, 1);
font-size: 14px;
border-radius: 160px;
border-width: 5px 3px;
border-style: solid;
border-color: rgba(79, 150, 68, 1) !important;
background-color: rgba(98, 190, 84, 1) !important;
box-shadow: 0 0 6px rgba(255, 255, 255, 0);
box-sizing: initial;
display: flex;
align-items: center;
justify-content: flex-start;
box-sizing: border-box;
.el-icon-menu {
margin: 0 5px 0 0;
padding: 0;
width: 24px;
line-height: 24px;
color: rgba(199, 21, 133, 1);
font-size: 16px;
border-radius: 0;
border-width: 0;
border-style: solid;
border-color: #fff;
background-color: rgba(255, 255, 255, 0);
box-shadow: 0 0 6px rgba(255, 255, 255, 0);
}
}
.index-aside-inner {
height: 100%;
margin-right: -17px;
margin-bottom: -17px;
overflow: scroll;
overflow-x: hidden !important;
padding-top: 80px;
.el-submenu {
margin: 0 0 10px 0;
}
& /deep/ .el-submenu__title {
width: auto;
height: auto !important;
line-height: 24px !important;
padding: 10px 22px 10px 10px;
color: rgba(255, 255, 255, 1);
font-size: 14px;
border-radius: 160px;
border-width: 5px 3px;
border-style: solid;
border-color: rgba(79, 150, 68, 1) !important;
background-color: rgba(98, 190, 84, 1) !important;
box-shadow: 0 0 6px rgba(255, 255, 255, 0);
box-sizing: initial;
display: flex;
align-items: center;
justify-content: flex-start;
box-sizing: border-box;
&:focus {
outline: none;
.el-icon-menu {
margin: 0 5px 0 0;
padding: 0;
width: 24px;
line-height: 24px;
color: rgba(199, 21, 133, 1);
font-size: 16px;
border-radius: 0;
border-width: 0;
border-style: solid;
border-color: #fff;
background-color: rgba(255, 255, 255, 0);
box-shadow: 0 0 6px rgba(255, 255, 255, 0);
}
& /deep/ .el-menu {
border: 0;
background-color: transparent;
.el-submenu__icon-arrow {
margin: 0 10px 0 0;
padding: 0;
width: 12px;
line-height: 12px;
color: rgba(255, 255, 255, 1) !important;
font-size: 12px;
border-radius: 0;
border-width: 0;
border-style: solid;
border-color: #fff;
background-color: rgba(255, 255, 255, 0);
box-shadow: 0 0 6px rgba(255, 255, 255, 0);
position: absolute;
top: 50%;
right: 0;
transform: translateY(-50%);
text-align: center;
display: block;
}
}
& /deep/ .el-menu.el-menu--inline {
width: 120px;
height: auto;
padding: 0;
margin: 0 auto 5px;
border-radius: 4px;
border-width: 0;
border-style: solid;
border-color: rgba(0, 0, 0, 0.3);
background-color: rgba(88, 171, 75, 1);
box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
.el-menu-item {
width: 100%;
height: 44px;
line-height: 44px;
padding: 0 !important;
margin: 0;
color: rgba(249, 249, 249, 1) !important;
font-size: 14px;
border-radius: 0;
border-width: 0 0 1px 0;
border-style: solid;
border-color: rgba(255, 255, 255, 0.75);
background-color: rgba(255, 255, 255, 0) !important;
box-shadow: 0 0 6px rgba(30, 144, 255, 0);
text-align: center;
min-width: auto;
&.is-active {
width: 100%;
height: 44px;
line-height: 44px;
padding: 0 !important;
margin: 0;
color: rgba(88, 171, 75, 1) !important;
font-size: 14px;
border-radius: 0;
border-width: 0;
border-style: solid;
border-color: rgba(0, 0, 0, 0);
background-color: rgba(255, 255, 255, 1) !important;
box-shadow: 0 0 6px rgba(30, 144, 255, 0);
text-align: center;
}
&:hover {
width: 100%;
height: 44px;
line-height: 44px;
padding: 0 !important;
margin: 0;
color: rgba(88, 171, 75, 1) !important;
font-size: 14px;
border-radius: 0;
border-width: 0;
border-style: solid;
border-color: rgba(0, 0, 0, 0);
background-color: rgba(255, 255, 255, 1) !important;
box-shadow: 0 0 6px rgba(30, 144, 255, 0);
text-align: center;
}
}
}
.index-aside .index-aside-inner.menulist {
height: auto !important;
}
.menulist-item {
width: 200px;
padding: 15px 20px;
margin: 0;
border-radius: 0;
border-width: 0 !important;
border-style: solid !important;
border-color: rgba(254, 236, 190, 1) !important;
background: #FEECBE !important;
box-shadow: 0 0 6px rgba(30, 144, 255, .2);
box-sizing: border-box;
}
.el-menu-demo {
box-sizing: border-box;
min-height: calc(100vh - 80px);
&>.el-menu-item {
width: auto;
height: auto !important;
line-height: 24px !important;
padding: 10px 22px 10px 10px;
margin: 0 0 10px 0;
color: rgba(255, 255, 255, 1);
font-size: 14px;
border-radius: 160px;
border-width: 5px 3px;
border-style: solid;
border-color: rgba(79, 150, 68, 1) !important;
background-color: rgba(98, 190, 84, 1) !important;
box-shadow: 0 0 6px rgba(255,255,255,0);
box-sizing: initial;
display: flex;
align-items: center;
justify-content: flex-start;
box-sizing: border-box;
.el-icon-menu {
margin: 0 5px 0 0;
padding: 0;
width: 24px;
line-height: 24px;
color: rgba(199, 21, 133, 1);
font-size: 16px;
border-radius: 0;
border-width: 0;
border-style: solid;
border-color: #fff;
background-color: rgba(255,255,255,0);
box-shadow: 0 0 6px rgba(255,255,255,0);
}
}
.el-submenu {
margin: 0 0 10px 0;
}
& /deep/ .el-submenu__title {
width: auto;
height: auto !important;
line-height: 24px !important;
padding: 10px 22px 10px 10px;
color: rgba(255, 255, 255, 1);
font-size: 14px;
border-radius: 160px;
border-width: 5px 3px;
border-style: solid;
border-color: rgba(79, 150, 68, 1) !important;
background-color: rgba(98, 190, 84, 1) !important;
box-shadow: 0 0 6px rgba(255,255,255,0);
box-sizing: initial;
display: flex;
align-items: center;
justify-content: flex-start;
box-sizing: border-box;
.el-icon-menu {
margin: 0 5px 0 0;
padding: 0;
width: 24px;
line-height: 24px;
color: rgba(199, 21, 133, 1);
font-size: 16px;
border-radius: 0;
border-width: 0;
border-style: solid;
border-color: #fff;
background-color: rgba(255,255,255,0);
box-shadow: 0 0 6px rgba(255,255,255,0);
}
.el-submenu__icon-arrow {
margin: 0 10px 0 0;
padding: 0;
width: 12px;
line-height: 12px;
color: rgba(255, 255, 255, 1) !important;
font-size: 12px;
border-radius: 0;
border-width: 0;
border-style: solid;
border-color: #fff;
background-color: rgba(255,255,255,0);
box-shadow: 0 0 6px rgba(255,255,255,0);
position: absolute;
top: 50%;
right: 0;
transform: translateY(-50%);
text-align: center;
display: block;
}
}
& /deep/ .el-menu.el-menu--inline {
width: 120px;
height: auto;
padding: 0;
margin: 0 auto 5px;
border-radius: 4px;
border-width: 0;
border-style: solid;
border-color: rgba(0,0,0,.3);
background-color: rgba(88, 171, 75, 1);
box-shadow: 0 0 6px rgba(0, 0, 0, .3);
.el-menu-item {
width: 100%;
height: 44px;
line-height: 44px;
padding: 0 !important;
margin: 0;
color: rgba(249, 249, 249, 1) !important;
font-size: 14px;
border-radius: 0;
border-width: 0 0 1px 0;
border-style: solid;
border-color: rgba(255, 255, 255, 0.75);
background-color: rgba(255, 255, 255, 0) !important;
box-shadow: 0 0 6px rgba(30, 144, 255, 0);
text-align: center;
min-width: auto;
&.is-active {
width: 100%;
height: 44px;
line-height: 44px;
padding: 0 !important;
margin: 0;
color: rgba(88, 171, 75, 1) !important;
font-size: 14px;
border-radius: 0;
border-width: 0;
border-style: solid;
border-color: rgba(0, 0, 0, 0);
background-color: rgba(255, 255, 255, 1) !important;
box-shadow: 0 0 6px rgba(30, 144, 255, 0);
text-align: center;
}
&:hover {
width: 100%;
height: 44px;
line-height: 44px;
padding: 0 !important;
margin: 0;
color: rgba(88, 171, 75, 1) !important;
font-size: 14px;
border-radius: 0;
border-width: 0;
border-style: solid;
border-color: rgba(0, 0, 0, 0);
background-color: rgba(255, 255, 255, 1) !important;
box-shadow: 0 0 6px rgba(30, 144, 255, 0);
text-align: center;
}
}
}
}
}
</style>
<style>
}
/* 弹出菜单样式 */
<style>
.el-menu--horizontal .el-menu--popup {
width: 120px;
height: auto;
padding: 0;
margin: 0 auto 5px;
border-radius: 4px;
border-width: 0;
border-style: solid;
border-color: rgba(0,0,0,.3);
background-color: rgba(88, 171, 75, 1);
box-shadow: 0 0 6px rgba(0, 0, 0, .3);
min-width: auto;
}
width: 120px;
height: auto;
padding: 0;
margin: 0 auto 5px;
border-radius: 4px;
border-width: 0;
border-style: solid;
border-color: rgba(0, 0, 0, 0.3);
background-color: rgba(88, 171, 75, 1);
box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
min-width: auto;
}
.el-menu--horizontal .el-menu--popup .el-menu-item {
width: 100%;
height: 44px;
line-height: 44px;
padding: 0;
margin: 0;
color: rgba(249, 249, 249, 1) !important;
font-size: 14px;
border-radius: 0;
border-width: 0 0 1px 0;
border-style: solid;
border-color: rgba(255, 255, 255, 0.75);
background-color: rgba(255, 255, 255, 0) !important;
box-shadow: 0 0 6px rgba(30, 144, 255, 0);
text-align: center;
min-width: auto;
}
.el-menu--horizontal .el-menu--popup .el-menu-item:hover {
width: 100%;
height: 44px;
line-height: 44px;
padding: 0;
margin: 0;
color: rgba(88, 171, 75, 1) !important;
font-size: 14px;
border-radius: 0;
border-width: 0;
border-style: solid;
border-color: rgba(0, 0, 0, 0);
background-color: rgba(255, 255, 255, 1) !important;
box-shadow: 0 0 6px rgba(30, 144, 255, 0);
text-align: center;
}
</style>
width: 100%;
height: 44px;
line-height: 44px;
padding: 0;
margin: 0;
color: rgba(249, 249, 249, 1) !important;
font-size: 14px;
border-radius: 0;
border-width: 0 0 1px 0;
border-style: solid;
border-color: rgba(255, 255, 255, 0.75);
background-color: rgba(255, 255, 255, 0) !important;
box-shadow: 0 0 6px rgba(30, 144, 255, 0);
text-align: center;
min-width: auto;
}
.el-menu--horizontal .el-menu--popup .el-menu-item:hover {
width: 100%;
height: 44px;
line-height: 44px;
padding: 0;
margin: 0;
color: rgba(88, 171, 75, 1) !important;
font-size: 14px;
border-radius: 0;
border-width: 0;
border-style: solid;
border-color: rgba(0, 0, 0, 0);
background-color: rgba(255, 255, 255, 1) !important;
box-shadow: 0 0 6px rgba(30, 144, 255, 0);
text-align: center;
}
</style>

@ -1,49 +1,60 @@
<template>
<!-- 如果当前菜单有子菜单且长度大于等于1则渲染一个子菜单 -->
<el-submenu v-if="menu.list && menu.list.length >= 1" :index="menu.menuId + ''">
<!-- 设置子菜单的标题区域 -->
<template slot="title">
<!-- 显示子菜单的名称 -->
<span>{{ menu.name }}</span>
</template>
<!-- 遍历当前菜单的子菜单并递归渲染 -->
<sub-menu
v-for="item in menu.list"
:key="item.menuId"
:menu="item"
:dynamicMenuRoutes="dynamicMenuRoutes"
:key="item.menuId" <!-- 为每个子菜单设置唯一的 key -->
:menu="item" <!-- 将子菜单对象传递给子组件 -->
:dynamicMenuRoutes="dynamicMenuRoutes" <!-- 将动态路由传递给子组件 -->
></sub-menu>
</el-submenu>
<!-- 如果没有子菜单则直接渲染菜单项 -->
<el-menu-item v-else :index="menu.menuId + ''" @click="gotoRouteHandle(menu)">
<!-- 显示菜单项的名称 -->
<span>{{ menu.name }}</span>
</el-menu-item>
</template>
<!-- 导入子菜单组件 -->
<script>
import SubMenu from "./IndexAsideSub";
export default {
name: "sub-menu",
props: {
menu: {
name: "sub-menu", <!-- 定义组件名称 -->
props: { <!-- 定义接收的属性 -->
menu: { <!-- 当前菜单对象 -->
type: Object,
required: true
},
dynamicMenuRoutes: {
dynamicMenuRoutes: { <!-- 动态路由数组 -->
type: Array,
required: true
}
},
components: {
components: { <!-- 注册子组件 -->
SubMenu
},
methods: {
methods: { <!-- 定义方法 -->
// menuId()
gotoRouteHandle(menu) {
// ID
var route = this.dynamicMenuRoutes.filter(
item => item.meta.menuId === menu.menuId
);
if (route.length >= 1) {
if (route[0].component != null) {
this.$router.replace({ name: route[0].name });
} else {
this.$router.push({ name: "404" });
if (route.length >= 1) { <!-- 如果找到匹配的路由 -->
if (route[0].component != null) { <!-- 如果组件存在 -->
this.$router.replace({ name: route[0].name }); <!-- 跳转到对应路由 -->
} else { <!-- 如果组件不存在 -->
this.$router.push({ name: "404" }); <!-- 跳转到404页面 -->
}
} else { <!-- 如果未找到路由 -->
console.warn("未找到对应的路由"); <!-- 记录警告日志 -->
}
}
}

@ -1,185 +1,169 @@
<template>
<!-- <el-header>
<el-menu background-color="#00c292" text-color="#FFFFFF" active-text-color="#FFFFFF" mode="horizontal">
<div class="fl title">{{this.$project.projectName}}</div>
<div class="fr logout" style="display:flex;">
<el-menu-item index="3">
<div>{{this.$storage.get('role')}} {{this.$storage.get('adminName')}}</div>
</el-menu-item>
<el-menu-item @click="onLogout" index="2">
<div>退出登录</div>
</el-menu-item>
</div>
</el-menu>
</el-header> -->
<div class="navbar" :style="{background:heads.headBgColor,height:heads.headHeight,boxShadow:heads.headBoxShadow,lineHeight:heads.headHeight}">
<div class="title-menu" :style="{justifyContent:heads.headTitleStyle=='1'?'flex-start':'center'}">
<el-image v-if="heads.headTitleImg" class="title-img" :style="{width:heads.headTitleImgWidth,height:heads.headTitleImgHeight,boxShadow:heads.headTitleImgBoxShadow,borderRadius:heads.headTitleImgBorderRadius}" :src="heads.headTitleImgUrl" fit="cover"></el-image>
<div class="title-name" :style="{color:heads.headFontColor,fontSize:heads.headFontSize}">{{this.$project.projectName}}</div>
</div>
<div class="right-menu">
<div class="user-info" :style="{color:heads.headUserInfoFontColor,fontSize:heads.headUserInfoFontSize}">{{this.$storage.get('role')}} {{this.$storage.get('adminName')}}</div>
<div v-if="this.$storage.get('role')!='管理员'" class="logout" :style="{color:heads.headLogoutFontColor,fontSize:heads.headLogoutFontSize}" @click="onIndexTap">退</div>
<div class="logout" :style="{color:heads.headLogoutFontColor,fontSize:heads.headLogoutFontSize}" @click="onLogout">退</div>
</div>
</div>
<div class="navbar" :style="{background:heads.headBgColor,height:heads.headHeight,boxShadow:heads.headBoxShadow,lineHeight:heads.headHeight}">
<!-- 左侧标题部分 -->
<div class="title-menu" :style="{justifyContent:heads.headTitleStyle=='1'?'flex-start':'center'}">
<!-- 如果头像图片存在则显示头像 -->
<el-image v-if="heads.headTitleImg" class="title-img" :style="{width:heads.headTitleImgWidth,height:heads.headTitleImgHeight,boxShadow:heads.headTitleImgBoxShadow,borderRadius:heads.headTitleImgBorderRadius}" :src="heads.headTitleImgUrl" fit="cover"></el-image>
<!-- 显示项目名称 -->
<div class="title-name" :style="{color:heads.headFontColor,fontSize:heads.headFontSize}">{{this.$project.projectName}}</div>
</div>
<!-- 右侧用户信息和退出按钮 -->
<div class="right-menu">
<!-- 用户信息 -->
<div class="user-info" :style="{color:heads.headUserInfoFontColor,fontSize:heads.headUserInfoFontSize}">{{this.$storage.get('role')}} {{this.$storage.get('adminName')}}</div>
<!-- 如果角色不是管理员则显示退出到前台按钮 -->
<div v-if="this.$storage.get('role')!='管理员'" class="logout" :style="{color:heads.headLogoutFontColor,fontSize:heads.headLogoutFontSize}" @click="onIndexTap">退</div>
<!-- 退出登录按钮 -->
<div class="logout" :style="{color:heads.headLogoutFontColor,fontSize:heads.headLogoutFontSize}" @click="onLogout">退</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
dialogVisible: false,
ruleForm: {},
user: {},
heads: {"headLogoutFontHoverColor":"#fff","headFontSize":"20px","headUserInfoFontColor":"rgba(98, 190, 84, 1)","headBoxShadow":"0 1px 6px #444","headTitleImgHeight":"44px","headLogoutFontHoverBgColor":"rgba(193, 193, 193, 0.55)","headFontColor":"rgba(98, 190, 84, 1)","headTitleImg":false,"headHeight":"80px","headTitleImgBorderRadius":"22px","headTitleImgUrl":"http://codegen.caihongy.cn/20201021/cc7d45d9c8164b58b18351764eba9be1.jpg","headBgColor":"#fff url(\"http://codegen.caihongy.cn/20211129/dcfd98cdd41848e38b8e78e5b2092ada.png\") repeat top","headTitleImgBoxShadow":"0 1px 6px #444","headLogoutFontColor":"rgba(98, 190, 84, 1)","headUserInfoFontSize":"16px","headTitleImgWidth":"44px","headTitleStyle":"2","headLogoutFontSize":"16px"},
};
},
created() {
this.setHeaderStyle()
},
mounted() {
let sessionTable = this.$storage.get("sessionTable")
this.$http({
url: sessionTable + '/session',
method: "get"
}).then(({
data
}) => {
if (data && data.code === 0) {
this.user = data.data;
this.$storage.set('userid',data.data.id);
} else {
let message = this.$message
message.error(data.msg);
}
});
},
methods: {
onLogout() {
let storage = this.$storage
let router = this.$router
storage.clear()
router.replace({
name: "login"
});
},
onIndexTap(){
window.location.href = `${this.$base.indexUrl}`
},
setHeaderStyle() {
this.$nextTick(()=>{
document.querySelectorAll('.navbar .right-menu .logout').forEach(el=>{
el.addEventListener("mouseenter", e => {
e.stopPropagation()
el.style.backgroundColor = this.heads.headLogoutFontHoverBgColor
el.style.color = this.heads.headLogoutFontHoverColor
})
el.addEventListener("mouseleave", e => {
e.stopPropagation()
el.style.backgroundColor = "transparent"
el.style.color = this.heads.headLogoutFontColor
})
})
})
},
}
};
export default {
data() {
return {
dialogVisible: false,
ruleForm: {},
user: {},
heads: {
"headLogoutFontHoverColor": "#fff",
"headFontSize": "20px",
"headUserInfoFontColor": "rgba(98, 190, 84, 1)",
"headBoxShadow": "0 1px 6px #444",
"headTitleImgHeight": "44px",
"headLogoutFontHoverBgColor": "rgba(193, 193, 193, 0.55)",
"headFontColor": "rgba(98, 190, 84, 1)",
"headTitleImg": false,
"headHeight": "80px",
"headTitleImgBorderRadius": "22px",
"headTitleImgUrl": "http://codegen.caihongy.cn/20201021/cc7d45d9c8164b58b18351764eba9be1.jpg",
"headBgColor": "#fff url(\\"http://codegen.caihongy.cn/20211129/dcfd98cdd41848e38b8e78e5b2092ada.png\\") repeat top",
"headTitleImgBoxShadow": "0 1px 6px #444",
"headLogoutFontColor": "rgba(98, 190, 84, 1)",
"headUserInfoFontSize": "16px",
"headTitleImgWidth": "44px",
"headTitleStyle": "2",
"headLogoutFontSize": "16px"
};
};
},
created() {
//
this.setHeaderStyle();
},
mounted() {
let sessionTable = this.$storage.get("sessionTable");
//
this.$http({
url: sessionTable + "/session",
method: "get"
}).then(({ data }) => {
if (data && data.code === 0) {
// user
this.user = data.data;
this.$storage.set("userid", data.data.id);
} else {
//
let message = this.$message;
message.error(data.msg);
}
});
},
methods: {
// 退
onLogout() {
let storage = this.$storage;
let router = this.$router;
//
storage.clear();
router.replace({
name: "login"
});
},
// 退
onIndexTap() {
//
window.location.href = `${this.$base.indexUrl}`;
},
//
setHeaderStyle() {
this.$nextTick(() => {
document.querySelectorAll('.navbar .right-menu .logout').forEach(el => {
el.addEventListener("mouseenter", e => {
e.stopPropagation();
//
el.style.backgroundColor = this.heads.headLogoutFontHoverBgColor;
el.style.color = this.heads.headLogoutFontHoverColor;
});
el.addEventListener("mouseleave", e => {
e.stopPropagation();
//
el.style.backgroundColor = "transparent";
el.style.color = this.heads.headLogoutFontColor;
});
});
});
},
}
};
</script>
<style lang="scss" scoped>
.navbar {
height: 60px;
line-height: 60px;
width: 100%;
padding: 0 34px;
box-sizing: border-box;
background-color: #ff00ff;
position: relative;
z-index: 111;
.right-menu {
position: absolute;
right: 34px;
top: 0;
height: 100%;
display: flex;
justify-content: flex-end;
align-items: center;
z-index: 111;
.user-info {
font-size: 16px;
color: red;
padding: 0 12px;
}
.logout {
font-size: 16px;
color: red;
padding: 0 12px;
cursor: pointer;
}
}
.title-menu {
display: flex;
justify-content: flex-start;
align-items: center;
width: 100%;
height: 100%;
.title-img {
width: 44px;
height: 44px;
border-radius: 22px;
box-shadow: 0 1px 6px #444;
margin-right: 16px;
}
.title-name {
font-size: 24px;
color: #fff;
font-weight: 700;
}
}
}
// .el-header .fr {
// float: right;
// }
.navbar {
height: 60px; /* 设置导航栏高度 */
line-height: 60px; /* 设置文本垂直居中 */
width: 100%; /* 设置宽度为100% */
padding: 0 34px; /* 设置左右内边距 */
box-sizing: border-box; /* 确保padding不会增加总宽度 */
background-color: #ff00ff; /* 设置背景颜色 */
position: relative; /* 相对定位 */
z-index: 111; /* 设置堆叠顺序 */
.right-menu {
position: absolute; /* 绝对定位 */
right: 34px; /* 右侧距离 */
top: 0; /* 顶部对齐 */
height: 100%; /* 占据整个高度 */
display: flex; /* 弹性布局 */
justify-content: flex-end; /* 内容右对齐 */
align-items: center; /* 垂直居中 */
z-index: 111; /* 设置堆叠顺序 */
// .el-header .fl {
// float: left;
// }
.user-info {
font-size: 16px; /* 字体大小 */
color: red; /* 文字颜色 */
padding: 0 12px; /* 内边距 */
}
// .el-header {
// width: 100%;
// color: #333;
// text-align: center;
// line-height: 60px;
// padding: 0;
// z-index: 99;
// }
.logout {
font-size: 16px; /* 字体大小 */
color: red; /* 文字颜色 */
padding: 0 12px; /* 内边距 */
cursor: pointer; /* 鼠标悬停时显示手型 */
}
}
// .logo {
// width: 60px;
// height: 60px;
// margin-left: 70px;
// }
.title-menu {
display: flex; /* 弹性布局 */
justify-content: flex-start; /* 内容左对齐 */
align-items: center; /* 垂直居中 */
width: 100%; /* 占据整个宽度 */
height: 100%; /* 占据整个高度 */
// .avator {
// width: 40px;
// height: 40px;
// background: #ffffff;
// border-radius: 50%;
// }
.title-img {
width: 44px; /* 图片宽度 */
height: 44px; /* 图片高度 */
border-radius: 22px; /* 圆角 */
box-shadow: 0 1px 6px #444; /* 添加阴影 */
margin-right: 16px; /* 图片右侧间距 */
}
// .title {
// color: #ffffff;
// font-size: 20px;
// font-weight: bold;
// margin-left: 20px;
// }
</style>
.title-name {
font-size: 24px; /* 字体大小 */
color: #fff; /* 文字颜色 */
font-weight: 700; /* 加粗 */
}
}
}
</style>

@ -4,6 +4,7 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
<<<<<<< HEAD
/**
*
@ -11,5 +12,14 @@ import java.lang.annotation.Target;
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface APPLoginUser {
=======
>>>>>>> main
/**
* APPLoginUser
*
*/
@Target(ElementType.PARAMETER) // 表明该注解只能用于方法参数上
@Retention(RetentionPolicy.RUNTIME) // 注解在运行时可用,可以通过反射获取
public @interface APPLoginUser {
}

@ -2,12 +2,25 @@ package com.annotation;
import java.lang.annotation.*;
<<<<<<< HEAD
/**
* Token
*/
=======
// 定义一个自定义注解名为 IgnoreAuth
// 使用 @Target 注解指定该注解可以应用的目标元素类型为方法ElementType.METHOD
>>>>>>> main
@Target(ElementType.METHOD)
// 使用 @Retention 注解指定该注解在运行时是否可用
// RetentionPolicy.RUNTIME 表示该注解在运行时可以通过反射获取
@Retention(RetentionPolicy.RUNTIME)
// 使用 @Documented 注解表示该注解会被包含在 JavaDoc 文档中
@Documented
// 定义一个空的自定义注解 IgnoreAuth
public @interface IgnoreAuth {
}

@ -4,12 +4,23 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
<<<<<<< HEAD
/**
*
*/
=======
// 定义一个自定义注解名为 LoginUser
// 使用 @Target 注解指定该注解可以应用的目标元素类型为参数ElementType.PARAMETER
>>>>>>> main
@Target(ElementType.PARAMETER)
// 使用 @Retention 注解指定该注解在运行时是否可用
// RetentionPolicy.RUNTIME 表示该注解在运行时可以通过反射获取
@Retention(RetentionPolicy.RUNTIME)
// 定义一个空的自定义注解 LoginUser
public @interface LoginUser {
}

@ -9,6 +9,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupp
import com.interceptor.AuthorizationInterceptor;
@Configuration
<<<<<<< HEAD
public class InterceptorConfig extends WebMvcConfigurationSupport{
@Bean
@ -26,13 +27,40 @@ public class InterceptorConfig extends WebMvcConfigurationSupport{
* springboot 2.0WebMvcConfigurationSupport访addResourceHandlers
*/
@Override
=======
public class InterceptorConfig extends WebMvcConfigurationSupport {
// 定义一个 Bean 方法,返回 AuthorizationInterceptor 的实例
@Bean
public AuthorizationInterceptor getAuthorizationInterceptor() {
return new AuthorizationInterceptor(); // 创建并返回一个新的 AuthorizationInterceptor 实例
}
// 重写 addInterceptors 方法,添加自定义拦截器
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 将 AuthorizationInterceptor 添加到拦截器链中
registry.addInterceptor(getAuthorizationInterceptor())
.addPathPatterns("/**") // 匹配所有路径
.excludePathPatterns("/static/**"); // 排除对 /static/** 路径的拦截
super.addInterceptors(registry); // 调用父类方法继续处理其他拦截器
}
/**
* 使 Spring Boot 2.0 WebMvcConfigurationSupport
* addResourceHandlers 访
*/
@Override
>>>>>>> main
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**")
.addResourceLocations("classpath:/resources/")
.addResourceLocations("classpath:/static/")
.addResourceLocations("classpath:/admin/")
.addResourceLocations("classpath:/front/")
.addResourceLocations("classpath:/public/");
super.addResourceHandlers(registry);
// 添加资源处理器,处理所有路径的静态资源请求
registry.addResourceHandler("/**")
.addResourceLocations("classpath:/resources/") // 从 classpath:/resources/ 目录加载资源
.addResourceLocations("classpath:/static/") // 从 classpath:/static/ 目录加载资源
.addResourceLocations("classpath:/admin/") // 从 classpath:/admin/ 目录加载资源
.addResourceLocations("classpath:/front/") // 从 classpath:/front/ 目录加载资源
.addResourceLocations("classpath:/public/"); // 从 classpath:/public/ 目录加载资源
super.addResourceHandlers(registry); // 调用父类方法继续处理其他资源处理器
}
}

@ -18,7 +18,7 @@ public class MybatisPlusConfig {
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
return new PaginationInterceptor(); // 创建并返回一个新的 PaginationInterceptor 实例
}
}

@ -34,14 +34,19 @@ import com.service.ConfigService;
import com.utils.BaiduUtil;
import com.utils.FileUtil;
import com.utils.R;
<<<<<<< HEAD
/**
*
=======
/**
*
>>>>>>> main
*/
@RestController
public class CommonController{
@Autowired
private CommonService commonService;
public class CommonController {
<<<<<<< HEAD
private static AipFace client = null;
@Autowired
@ -51,52 +56,91 @@ public class CommonController{
* @param table
* @param column
* @return
=======
@Autowired
private CommonService commonService; // 注入通用服务
private static AipFace client = null; // 百度人脸API客户端实例
@Autowired
private ConfigService configService; // 注入配置服务
/**
* tablecolumn()
* @param tableName
* @param columnName
* @param level
* @param parent
* @return
>>>>>>> main
*/
@IgnoreAuth
@RequestMapping("/option/{tableName}/{columnName}")
public R getOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,String level,String parent) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("table", tableName);
params.put("column", columnName);
if(StringUtils.isNotBlank(level)) {
params.put("level", level);
public R getOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,
String level, String parent) {
Map<String, Object> params = new HashMap<String, Object>(); // 参数封装
params.put("table", tableName); // 添加表名
params.put("column", columnName); // 添加列名
if (StringUtils.isNotBlank(level)) { // 如果层级不为空
params.put("level", level); // 添加层级
}
if(StringUtils.isNotBlank(parent)) {
params.put("parent", parent);
if (StringUtils.isNotBlank(parent)) { // 如果父节点不为空
params.put("parent", parent); // 添加父节点
}
List<String> data = commonService.getOption(params);
return R.ok().put("data", data);
List<String> data = commonService.getOption(params); // 调用服务获取数据
return R.ok().put("data", data); // 返回成功结果
}
<<<<<<< HEAD
/**
* tablecolumn
* @param table
* @param column
* @return
=======
/**
* tablecolumn
* @param tableName
* @param columnName
* @param columnValue
* @return
>>>>>>> main
*/
@IgnoreAuth
@RequestMapping("/follow/{tableName}/{columnName}")
public R getFollowByOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, @RequestParam String columnValue) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("table", tableName);
params.put("column", columnName);
params.put("columnValue", columnValue);
Map<String, Object> result = commonService.getFollowByOption(params);
return R.ok().put("data", result);
public R getFollowByOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,
@RequestParam String columnValue) {
Map<String, Object> params = new HashMap<String, Object>(); // 参数封装
params.put("table", tableName); // 添加表名
params.put("column", columnName); // 添加列名
params.put("columnValue", columnValue); // 添加列值
Map<String, Object> result = commonService.getFollowByOption(params); // 调用服务获取结果
return R.ok().put("data", result); // 返回成功结果
}
<<<<<<< HEAD
/**
* tablesfsh
* @param table
* @param map
* @return
=======
/**
* tablesfsh
* @param tableName
* @param map
* @return
>>>>>>> main
*/
@RequestMapping("/sh/{tableName}")
public R sh(@PathVariable("tableName") String tableName, @RequestBody Map<String, Object> map) {
map.put("table", tableName);
commonService.sh(map);
return R.ok();
map.put("table", tableName); // 添加表名
commonService.sh(map); // 调用服务修改状态
return R.ok(); // 返回成功结果
}
<<<<<<< HEAD
/**
*
@ -105,165 +149,190 @@ public class CommonController{
* @param type 1: 2:
* @param map
* @return
=======
/**
*
* @param tableName
* @param columnName
* @param type 1:, 2:
* @param map
* @return
>>>>>>> main
*/
@IgnoreAuth
@RequestMapping("/remind/{tableName}/{columnName}/{type}")
public R remindCount(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("table", tableName);
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
public R remindCount(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("table", tableName); // 添加表名
map.put("column", columnName); // 添加列名
map.put("type", type); // 添加提醒类型
if ("2".equals(type)) { // 如果类型为日期
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 日期格式化工具
Calendar c = Calendar.getInstance(); // 日历实例
Date remindStartDate = null; // 提醒开始日期
Date remindEndDate = null; // 提醒结束日期
if (map.get("remindstart") != null) { // 如果有提醒开始时间
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前时间为基准
c.add(Calendar.DAY_OF_MONTH, remindStart); // 增加天数
remindStartDate = c.getTime(); // 获取新的日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并更新参数
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前时间为基准
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 增加天数
remindEndDate = c.getTime(); // 获取新的日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并更新参数
}
}
int count = commonService.remindCount(map);
return R.ok().put("count", count);
int count = commonService.remindCount(map); // 调用服务获取提醒记录数
return R.ok().put("count", count); // 返回成功结果
}
/**
*
* @param tableName
* @param columnName
* @return
*/
@IgnoreAuth
@RequestMapping("/cal/{tableName}/{columnName}")
public R cal(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("table", tableName);
params.put("column", columnName);
Map<String, Object> result = commonService.selectCal(params);
return R.ok().put("data", result);
Map<String, Object> params = new HashMap<String, Object>(); // 参数封装
params.put("table", tableName); // 添加表名
params.put("column", columnName); // 添加列名
Map<String, Object> result = commonService.selectCal(params); // 调用服务获取求和结果
return R.ok().put("data", result); // 返回成功结果
}
/**
*
* @param tableName
* @param columnName
* @return
*/
@IgnoreAuth
@RequestMapping("/group/{tableName}/{columnName}")
public R group(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("table", tableName);
params.put("column", columnName);
List<Map<String, Object>> result = commonService.selectGroup(params);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for(Map<String, Object> m : result) {
for(String k : m.keySet()) {
if(m.get(k) instanceof Date) {
m.put(k, sdf.format((Date)m.get(k)));
Map<String, Object> params = new HashMap<String, Object>(); // 参数封装
params.put("table", tableName); // 添加表名
params.put("column", columnName); // 添加列名
List<Map<String, Object>> result = commonService.selectGroup(params); // 调用服务获取分组统计结果
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 日期格式化工具
for (Map<String, Object> m : result) { // 遍历结果
for (String k : m.keySet()) { // 遍历键
if (m.get(k) instanceof Date) { // 如果值是日期类型
m.put(k, sdf.format((Date) m.get(k))); // 格式化日期
}
}
}
return R.ok().put("data", result);
return R.ok().put("data", result); // 返回成功结果
}
/**
*
* @param tableName
* @param yColumnName Y
* @param xColumnName X
* @return
*/
@IgnoreAuth
@RequestMapping("/value/{tableName}/{xColumnName}/{yColumnName}")
public R value(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("table", tableName);
params.put("xColumn", xColumnName);
params.put("yColumn", yColumnName);
List<Map<String, Object>> result = commonService.selectValue(params);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for(Map<String, Object> m : result) {
for(String k : m.keySet()) {
if(m.get(k) instanceof Date) {
m.put(k, sdf.format((Date)m.get(k)));
public R value(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName,
@PathVariable("xColumnName") String xColumnName) {
Map<String, Object> params = new HashMap<String, Object>(); // 参数封装
params.put("table", tableName); // 添加表名
params.put("xColumn", xColumnName); // 添加X轴列名
params.put("yColumn", yColumnName); // 添加Y轴列名
List<Map<String, Object>> result = commonService.selectValue(params); // 调用服务获取按值统计结果
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 日期格式化工具
for (Map<String, Object> m : result) { // 遍历结果
for (String k : m.keySet()) { // 遍历键
if (m.get(k) instanceof Date) { // 如果值是日期类型
m.put(k, sdf.format((Date) m.get(k))); // 格式化日期
}
}
}
return R.ok().put("data", result);
return R.ok().put("data", result); // 返回成功结果
}
/**
*
*
* @param tableName
* @param xColumnName X
* @param yColumnName Y
* @param timeStatType
* @return
*/
@IgnoreAuth
@RequestMapping("/value/{tableName}/{xColumnName}/{yColumnName}/{timeStatType}")
public R valueDay(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName, @PathVariable("timeStatType") String timeStatType) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("table", tableName);
params.put("xColumn", xColumnName);
params.put("yColumn", yColumnName);
params.put("timeStatType", timeStatType);
List<Map<String, Object>> result = commonService.selectTimeStatValue(params);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for(Map<String, Object> m : result) {
for(String k : m.keySet()) {
if(m.get(k) instanceof Date) {
m.put(k, sdf.format((Date)m.get(k)));
public R valueDay(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName,
@PathVariable("xColumnName") String xColumnName, @PathVariable("timeStatType") String timeStatType) {
Map<String, Object> params = new HashMap<String, Object>(); // 参数封装
params.put("table", tableName); // 添加表名
params.put("xColumn", xColumnName); // 添加X轴列名
params.put("yColumn", yColumnName); // 添加Y轴列名
params.put("timeStatType", timeStatType); // 添加时间统计类型
List<Map<String, Object>> result = commonService.selectTimeStatValue(params); // 调用服务获取按值统计结果
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 日期格式化工具
for (Map<String, Object> m : result) { // 遍历结果
for (String k : m.keySet()) { // 遍历键
if (m.get(k) instanceof Date) { // 如果值是日期类型
m.put(k, sdf.format((Date) m.get(k))); // 格式化日期
}
}
}
return R.ok().put("data", result);
return R.ok().put("data", result); // 返回成功结果
}
/**
*
* @param face1 1
* @param face2 2
* @param request HTTP
* @return
*/
@RequestMapping("/matchFace")
@IgnoreAuth
public R matchFace(String face1, String face2, HttpServletRequest request) {
if (client == null) { // 如果客户端未初始化
/*String AppID = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "AppID")).getValue();*/
String APIKey = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "APIKey")).getValue(); // 获取API Key
String SecretKey = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "SecretKey")).getValue(); // 获取Secret Key
String token = BaiduUtil.getAuth(APIKey, SecretKey); // 获取访问令牌
if (token == null) { // 如果令牌为空
return R.error("请在配置管理中正确配置APIKey和SecretKey"); // 返回错误信息
}
client = new AipFace(null, APIKey, SecretKey); // 初始化客户端
client.setConnectionTimeoutInMillis(2000); // 设置连接超时时间
client.setSocketTimeoutInMillis(60000); // 设置套接字超时时间
}
JSONObject res = null; // 响应结果
try {
File path = new File(ResourceUtils.getURL("classpath:static").getPath()); // 获取静态资源路径
if (!path.exists()) { // 如果路径不存在
path = new File(""); // 使用当前目录
}
File upload = new File(path.getAbsolutePath(), "/upload/"); // 创建上传目录
File file1 = new File(upload.getAbsolutePath(), face1); // 文件1
File file2 = new File(upload.getAbsolutePath(), face2); // 文件2
String img1 = Base64Util.encode(FileUtil.FileToByte(file1)); // 将文件1转换为Base64
String img2 = Base64Util.encode(FileUtil.FileToByte(file2)); // 将文件2转换为Base64
MatchRequest req1 = new MatchRequest(img1, "BASE64"); // 第一个人脸请求
MatchRequest req2 = new MatchRequest(img2, "BASE64"); // 第二个人脸请求
ArrayList<MatchRequest> requests = new ArrayList<MatchRequest>(); // 请求列表
requests.add(req1); // 添加第一个请求
requests.add(req2); // 添加第二个请求
res = client.match(requests); // 调用人脸比对接口
System.out.println(res.get("result")); // 打印比对结果
} catch (FileNotFoundException e) { // 文件未找到异常
e.printStackTrace(); // 打印堆栈信息
return R.error("文件不存在"); // 返回错误信息
} catch (IOException e) { // IO异常
e.printStackTrace(); // 打印堆栈信息
}
return R.ok().put("score", com.alibaba.fastjson.JSONObject.parse(res.getJSONObject("result").get("score").toString())); // 返回比对分数
}
/**
*
*
* @param face1 1
* @param face2 2
* @return
*/
@RequestMapping("/matchFace")
@IgnoreAuth
public R matchFace(String face1, String face2,HttpServletRequest request) {
if(client==null) {
/*String AppID = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "AppID")).getValue();*/
String APIKey = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "APIKey")).getValue();
String SecretKey = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "SecretKey")).getValue();
String token = BaiduUtil.getAuth(APIKey, SecretKey);
if(token==null) {
return R.error("请在配置管理中正确配置APIKey和SecretKey");
}
client = new AipFace(null, APIKey, SecretKey);
client.setConnectionTimeoutInMillis(2000);
client.setSocketTimeoutInMillis(60000);
}
JSONObject res = null;
try {
File path = new File(ResourceUtils.getURL("classpath:static").getPath());
if(!path.exists()) {
path = new File("");
}
File upload = new File(path.getAbsolutePath(),"/upload/");
File file1 = new File(upload.getAbsolutePath()+"/"+face1);
File file2 = new File(upload.getAbsolutePath()+"/"+face2);
String img1 = Base64Util.encode(FileUtil.FileToByte(file1));
String img2 = Base64Util.encode(FileUtil.FileToByte(file2));
MatchRequest req1 = new MatchRequest(img1, "BASE64");
MatchRequest req2 = new MatchRequest(img2, "BASE64");
ArrayList<MatchRequest> requests = new ArrayList<MatchRequest>();
requests.add(req1);
requests.add(req2);
res = client.match(requests);
System.out.println(res.get("result"));
} catch (FileNotFoundException e) {
e.printStackTrace();
return R.error("文件不存在");
} catch (IOException e) {
e.printStackTrace();
}
return R.ok().put("score", com.alibaba.fastjson.JSONObject.parse(res.getJSONObject("result").get("score").toString()));
}
}

@ -1,7 +1,5 @@
package com.controller;
import java.util.Arrays;
import java.util.Map;
@ -23,90 +21,149 @@ import com.utils.R;
import com.utils.ValidatorUtils;
/**
*
*
*/
@RequestMapping("config")
@RestController
public class ConfigController{
@Autowired
private ConfigService configService;
public class ConfigController {
<<<<<<< HEAD
/**
*
=======
@Autowired
private ConfigService configService; // 注入配置服务
/**
*
* @param params
* @param config
* @return
>>>>>>> main
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,ConfigEntity config){
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>();
PageUtils page = configService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, config), params), params));
return R.ok().put("data", page);
public R page(@RequestParam Map<String, Object> params, ConfigEntity config) {
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); // 创建查询条件
PageUtils page = configService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, config), params), params)); // 查询分页数据
return R.ok().put("data", page); // 返回成功结果
}
<<<<<<< HEAD
/**
*
=======
/**
*
* @param params
* @param config
* @return
>>>>>>> main
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,ConfigEntity config){
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>();
PageUtils page = configService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, config), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, ConfigEntity config) {
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); // 创建查询条件
PageUtils page = configService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, config), params), params)); // 查询分页数据
return R.ok().put("data", page); // 返回成功结果
}
/**
<<<<<<< HEAD
*
=======
* ID
* @param id ID
* @return
>>>>>>> main
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id){
ConfigEntity config = configService.selectById(id);
return R.ok().put("data", config);
public R info(@PathVariable("id") String id) {
ConfigEntity config = configService.selectById(id); // 根据ID查询配置
return R.ok().put("data", config); // 返回成功结果
}
<<<<<<< HEAD
/**
*
=======
/**
* ID
* @param id ID
* @return
>>>>>>> main
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") String id){
ConfigEntity config = configService.selectById(id);
return R.ok().put("data", config);
public R detail(@PathVariable("id") String id) {
ConfigEntity config = configService.selectById(id); // 根据ID查询配置
return R.ok().put("data", config); // 返回成功结果
}
<<<<<<< HEAD
/**
* name
=======
/**
*
* @param name
* @return
>>>>>>> main
*/
@RequestMapping("/info")
public R infoByName(@RequestParam String name){
ConfigEntity config = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
return R.ok().put("data", config);
public R infoByName(@RequestParam String name) {
ConfigEntity config = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile")); // 根据名称查询配置
return R.ok().put("data", config); // 返回成功结果
}
<<<<<<< HEAD
/**
*
=======
/**
*
* @param config
* @return
>>>>>>> main
*/
@PostMapping("/save")
public R save(@RequestBody ConfigEntity config){
// ValidatorUtils.validateEntity(config);
configService.insert(config);
return R.ok();
public R save(@RequestBody ConfigEntity config) {
// ValidatorUtils.validateEntity(config); // 验证配置对象
configService.insert(config); // 插入配置
return R.ok(); // 返回成功结果
}
/**
<<<<<<< HEAD
*
=======
*
* @param config
* @return
>>>>>>> main
*/
@RequestMapping("/update")
public R update(@RequestBody ConfigEntity config){
// ValidatorUtils.validateEntity(config);
configService.updateById(config);//全部更新
return R.ok();
public R update(@RequestBody ConfigEntity config) {
// ValidatorUtils.validateEntity(config); // 验证配置对象
configService.updateById(config); // 根据ID更新配置
return R.ok(); // 返回成功结果
}
/**
<<<<<<< HEAD
*
=======
*
* @param ids ID
* @return
>>>>>>> main
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
configService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
configService.deleteBatchIds(Arrays.asList(ids)); // 批量删除配置
return R.ok(); // 返回成功结果
}
}

@ -1,14 +1,7 @@
package com.controller;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import com.utils.ValidatorUtils;
@ -16,11 +9,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.format.annotation.DateTimeFormat;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
@ -38,180 +28,192 @@ import com.utils.CommonUtil;
import java.io.IOException;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/discusshuodongxinde")
public class DiscusshuodongxindeController {
@Autowired
private DiscusshuodongxindeService discusshuodongxindeService;
private DiscusshuodongxindeService discusshuodongxindeService; // 注入服务类
/**
*
*
* @param params
* @param discusshuodongxinde
* @param request
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,DiscusshuodongxindeEntity discusshuodongxinde,
HttpServletRequest request){
EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<DiscusshuodongxindeEntity>();
PageUtils page = discusshuodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discusshuodongxinde), params), params));
return R.ok().put("data", page);
public R page(@RequestParam Map<String, Object> params, DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request) {
EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = discusshuodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discusshuodongxinde), params), params)); // 查询分页数据
return R.ok().put("data", page); // 返回成功结果
}
/**
*
*
* @param params
* @param discusshuodongxinde
* @param request
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,DiscusshuodongxindeEntity discusshuodongxinde,
HttpServletRequest request){
EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<DiscusshuodongxindeEntity>();
PageUtils page = discusshuodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discusshuodongxinde), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request) {
EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = discusshuodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discusshuodongxinde), params), params)); // 查询分页数据
return R.ok().put("data", page); // 返回成功结果
}
/**
*
/**
*
* @param discusshuodongxinde
* @return
*/
@RequestMapping("/lists")
public R list( DiscusshuodongxindeEntity discusshuodongxinde){
EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<DiscusshuodongxindeEntity>();
ew.allEq(MPUtil.allEQMapPre( discusshuodongxinde, "discusshuodongxinde"));
return R.ok().put("data", discusshuodongxindeService.selectListView(ew));
public R list(DiscusshuodongxindeEntity discusshuodongxinde) {
EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<>(); // 创建查询条件
ew.allEq(MPUtil.allEQMapPre(discusshuodongxinde, "discusshuodongxinde")); // 设置查询条件
return R.ok().put("data", discusshuodongxindeService.selectListView(ew)); // 返回查询结果
}
/**
*
/**
*
* @param discusshuodongxinde
* @return
*/
@RequestMapping("/query")
public R query(DiscusshuodongxindeEntity discusshuodongxinde){
EntityWrapper< DiscusshuodongxindeEntity> ew = new EntityWrapper< DiscusshuodongxindeEntity>();
ew.allEq(MPUtil.allEQMapPre( discusshuodongxinde, "discusshuodongxinde"));
DiscusshuodongxindeView discusshuodongxindeView = discusshuodongxindeService.selectView(ew);
return R.ok("查询活动心得评论表成功").put("data", discusshuodongxindeView);
public R query(DiscusshuodongxindeEntity discusshuodongxinde) {
EntityWrapper<DiscusshuodongxindeEntity> ew = new EntityWrapper<>(); // 创建查询条件
ew.allEq(MPUtil.allEQMapPre(discusshuodongxinde, "discusshuodongxinde")); // 设置查询条件
DiscusshuodongxindeView discusshuodongxindeView = discusshuodongxindeService.selectView(ew); // 查询视图数据
return R.ok("查询活动心得评论表成功").put("data", discusshuodongxindeView); // 返回查询结果
}
/**
*
*
* @param id ID
* @return ID
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
DiscusshuodongxindeEntity discusshuodongxinde = discusshuodongxindeService.selectById(id);
return R.ok().put("data", discusshuodongxinde);
public R info(@PathVariable("id") Long id) {
DiscusshuodongxindeEntity discusshuodongxinde = discusshuodongxindeService.selectById(id); // 根据ID查询数据
return R.ok().put("data", discusshuodongxinde); // 返回查询结果
}
/**
*
*
* @param id ID
* @return ID
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
DiscusshuodongxindeEntity discusshuodongxinde = discusshuodongxindeService.selectById(id);
return R.ok().put("data", discusshuodongxinde);
public R detail(@PathVariable("id") Long id) {
DiscusshuodongxindeEntity discusshuodongxinde = discusshuodongxindeService.selectById(id); // 根据ID查询数据
return R.ok().put("data", discusshuodongxinde); // 返回查询结果
}
/**
*
*
* @param discusshuodongxinde
* @param request
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request){
discusshuodongxinde.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(discusshuodongxinde);
discusshuodongxindeService.insert(discusshuodongxinde);
return R.ok();
public R save(@RequestBody DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request) {
discusshuodongxinde.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(discusshuodongxinde); // 验证数据
discusshuodongxindeService.insert(discusshuodongxinde); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param discusshuodongxinde
* @param request
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request){
discusshuodongxinde.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(discusshuodongxinde);
discusshuodongxindeService.insert(discusshuodongxinde);
return R.ok();
public R add(@RequestBody DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request) {
discusshuodongxinde.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(discusshuodongxinde); // 验证数据
discusshuodongxindeService.insert(discusshuodongxinde); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param discusshuodongxinde
* @param request
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request){
//ValidatorUtils.validateEntity(discusshuodongxinde);
discusshuodongxindeService.updateById(discusshuodongxinde);//全部更新
return R.ok();
@Transactional // 开启事务
public R update(@RequestBody DiscusshuodongxindeEntity discusshuodongxinde, HttpServletRequest request) {
// ValidatorUtils.validateEntity(discusshuodongxinde); // 验证数据
discusshuodongxindeService.updateById(discusshuodongxinde); // 根据ID更新数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
discusshuodongxindeService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
discusshuodongxindeService.deleteBatchIds(Arrays.asList(ids)); // 批量删除数据
return R.ok(); // 返回成功结果
}
/**
*
* @param columnName
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<DiscusshuodongxindeEntity> wrapper = new EntityWrapper<DiscusshuodongxindeEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = discusshuodongxindeService.selectCount(wrapper);
return R.ok().put("count", count);
}
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 添加字段名到参数
map.put("type", type); // 添加类型到参数
if (type.equals("2")) { // 如果类型为2
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有开始日期
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并存入参数
}
if (map.get("remindend") != null) { // 如果有结束日期
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并存入参数
}
}
Wrapper<DiscusshuodongxindeEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
int count = discusshuodongxindeService.selectCount(wrapper); // 统计符合条件的记录数
return R.ok().put("count", count); // 返回统计结果
}
}

@ -19,11 +19,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import com.annotation.IgnoreAuth;
@ -34,83 +30,95 @@ import com.service.ConfigService;
import com.utils.R;
/**
*
*
*/
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
public class FileController {
@Autowired
private ConfigService configService;
private ConfigService configService; // 注入配置服务类
/**
*
*
* @param file
* @param type 1
* @return
* @throws Exception
*/
@RequestMapping("/upload")
public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
if (file.isEmpty()) {
throw new EIException("上传文件不能为空");
public R upload(@RequestParam("file") MultipartFile file, String type) throws Exception {
if (file.isEmpty()) { // 检查文件是否为空
throw new EIException("上传文件不能为空"); // 抛出异常
}
String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
File path = new File(ResourceUtils.getURL("classpath:static").getPath());
if(!path.exists()) {
path = new File("");
String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); // 获取文件扩展名
File path = new File(ResourceUtils.getURL("classpath:static").getPath()); // 获取静态资源路径
if (!path.exists()) { // 如果路径不存在
path = new File(""); // 设置默认路径
}
File upload = new File(path.getAbsolutePath(),"/upload/");
if(!upload.exists()) {
upload.mkdirs();
File upload = new File(path.getAbsolutePath(), "/upload/"); // 定义上传目录
if (!upload.exists()) { // 如果上传目录不存在
upload.mkdirs(); // 创建目录
}
String fileName = new Date().getTime()+"."+fileExt;
File dest = new File(upload.getAbsolutePath()+"/"+fileName);
file.transferTo(dest);
String fileName = new Date().getTime() + "." + fileExt; // 生成唯一的文件名
File dest = new File(upload.getAbsolutePath() + "/" + fileName); // 定义目标文件路径
file.transferTo(dest); // 将文件保存到目标位置
/**
* 使ideaeclipse
* "D:\\springbootq33sd\\src\\main\\resources\\static\\upload"upload
*
*/
// FileUtils.copyFile(dest, new File("D:\\springbootq33sd\\src\\main\\resources\\static\\upload"+"/"+fileName)); /**修改了路径以后请将该行最前面的//注释去掉**/
if(StringUtils.isNotBlank(type) && type.equals("1")) {
ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
if(configEntity==null) {
configEntity = new ConfigEntity();
configEntity.setName("faceFile");
configEntity.setValue(fileName);
* 使IDEIntelliJ IDEAEclipse
* 1.
* 2. "D:\\\\springbootq33sd\\\\src\\\\main\\\\resources\\\\static\\\\upload"
* 3.
*/
// FileUtils.copyFile(dest, new File("D:\\\\springbootq33sd\\\\src\\\\main\\\\resources\\\\static\\\\upload\\\\" + fileName)); // 复制文件到指定路径
if (StringUtils.isNotBlank(type) && type.equals("1")) { // 如果类型为1人脸文件
ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile")); // 查询配置项
if (configEntity == null) { // 如果配置项不存在
configEntity = new ConfigEntity(); // 创建新配置项
configEntity.setName("faceFile"); // 设置配置项名称
configEntity.setValue(fileName); // 设置文件名
} else {
configEntity.setValue(fileName);
configEntity.setValue(fileName); // 更新文件名
}
configService.insertOrUpdate(configEntity);
configService.insertOrUpdate(configEntity); // 插入或更新配置项
}
return R.ok().put("file", fileName);
return R.ok().put("file", fileName); // 返回成功结果
}
/**
*
*
* @param fileName
* @return
*/
@IgnoreAuth
@RequestMapping("/download")
public ResponseEntity<byte[]> download(@RequestParam String fileName) {
try {
File path = new File(ResourceUtils.getURL("classpath:static").getPath());
if(!path.exists()) {
path = new File("");
File path = new File(ResourceUtils.getURL("classpath:static").getPath()); // 获取静态资源路径
if (!path.exists()) { // 如果路径不存在
path = new File(""); // 设置默认路径
}
File upload = new File(path.getAbsolutePath(),"/upload/");
if(!upload.exists()) {
upload.mkdirs();
File upload = new File(path.getAbsolutePath(), "/upload/"); // 定义上传目录
if (!upload.exists()) { // 如果上传目录不存在
upload.mkdirs(); // 创建目录
}
File file = new File(upload.getAbsolutePath()+"/"+fileName);
if(file.exists()){
/*if(!fileService.canRead(file, SessionManager.getSessionUser())){
getResponse().sendError(403);
}*/
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
headers.setContentDispositionFormData("attachment", fileName);
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
File file = new File(upload.getAbsolutePath() + "/" + fileName); // 定义目标文件路径
if (file.exists()) { // 如果文件存在
HttpHeaders headers = new HttpHeaders(); // 设置响应头
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); // 设置内容类型
headers.setContentDispositionFormData("attachment", fileName); // 设置附件下载
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file), headers, HttpStatus.OK); // 返回文件流
}
} catch (IOException e) {
e.printStackTrace();
e.printStackTrace(); // 打印异常日志
}
return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR); // 返回错误状态码
}
}

@ -38,188 +38,204 @@ import com.utils.CommonUtil;
import java.io.IOException;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/huodongbaoming")
public class HuodongbaomingController {
@Autowired
private HuodongbaomingService huodongbaomingService;
private HuodongbaomingService huodongbaomingService; // 注入活动报名服务
/**
*
* @param params
* @param huodongbaoming
* @param request HTTP
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,HuodongbaomingEntity huodongbaoming,
HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("zhiyuanzhe")) {
huodongbaoming.setXuehao((String)request.getSession().getAttribute("username"));
}
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<HuodongbaomingEntity>();
PageUtils page = huodongbaomingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongbaoming), params), params));
return R.ok().put("data", page);
public R page(@RequestParam Map<String, Object> params, HuodongbaomingEntity huodongbaoming,
HttpServletRequest request) {
String tableName = request.getSession().getAttribute("tableName").toString(); // 获取当前用户表名
if (tableName.equals("zhiyuanzhe")) { // 如果是志愿者表
huodongbaoming.setXuehao((String) request.getSession().getAttribute("username")); // 设置学号
}
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongbaomingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongbaoming), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
* @param params
* @param huodongbaoming
* @param request HTTP
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,HuodongbaomingEntity huodongbaoming,
HttpServletRequest request){
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<HuodongbaomingEntity>();
PageUtils page = huodongbaomingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongbaoming), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, HuodongbaomingEntity huodongbaoming,
HttpServletRequest request) {
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongbaomingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongbaoming), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
/**
*
* @param huodongbaoming
* @return
*/
@RequestMapping("/lists")
public R list( HuodongbaomingEntity huodongbaoming){
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<HuodongbaomingEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongbaoming, "huodongbaoming"));
return R.ok().put("data", huodongbaomingService.selectListView(ew));
public R list(HuodongbaomingEntity huodongbaoming) {
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongbaoming, "huodongbaoming")); // 设置查询条件
return R.ok().put("data", huodongbaomingService.selectListView(ew)); // 返回数据列表
}
/**
*
/**
*
* @param huodongbaoming
* @return
*/
@RequestMapping("/query")
public R query(HuodongbaomingEntity huodongbaoming){
EntityWrapper< HuodongbaomingEntity> ew = new EntityWrapper< HuodongbaomingEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongbaoming, "huodongbaoming"));
HuodongbaomingView huodongbaomingView = huodongbaomingService.selectView(ew);
return R.ok("查询活动报名成功").put("data", huodongbaomingView);
public R query(HuodongbaomingEntity huodongbaoming) {
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongbaoming, "huodongbaoming")); // 设置查询条件
HuodongbaomingView huodongbaomingView = huodongbaomingService.selectView(ew); // 查询视图
return R.ok("查询活动报名成功").put("data", huodongbaomingView); // 返回查询结果
}
/**
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
HuodongbaomingEntity huodongbaoming = huodongbaomingService.selectById(id);
return R.ok().put("data", huodongbaoming);
public R info(@PathVariable("id") Long id) {
HuodongbaomingEntity huodongbaoming = huodongbaomingService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongbaoming); // 返回记录详情
}
/**
*
* @param id ID
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
HuodongbaomingEntity huodongbaoming = huodongbaomingService.selectById(id);
return R.ok().put("data", huodongbaoming);
public R detail(@PathVariable("id") Long id) {
HuodongbaomingEntity huodongbaoming = huodongbaomingService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongbaoming); // 返回记录详情
}
/**
*
* @param huodongbaoming
* @param request HTTP
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request){
huodongbaoming.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongbaoming);
huodongbaomingService.insert(huodongbaoming);
return R.ok();
public R save(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request) {
huodongbaoming.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
huodongbaomingService.insert(huodongbaoming); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
* @param huodongbaoming
* @param request HTTP
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request){
huodongbaoming.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongbaoming);
huodongbaomingService.insert(huodongbaoming);
return R.ok();
public R add(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request) {
huodongbaoming.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
huodongbaomingService.insert(huodongbaoming); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param huodongbaoming
* @param request HTTP
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request){
//ValidatorUtils.validateEntity(huodongbaoming);
huodongbaomingService.updateById(huodongbaoming);//全部更新
return R.ok();
public R update(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request) {
huodongbaomingService.updateById(huodongbaoming); // 全量更新
return R.ok(); // 返回成功结果
}
/**
*
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
huodongbaomingService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
huodongbaomingService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
return R.ok(); // 返回成功结果
}
/**
*
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<HuodongbaomingEntity> wrapper = new EntityWrapper<HuodongbaomingEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("zhiyuanzhe")) {
wrapper.eq("xuehao", (String)request.getSession().getAttribute("username"));
}
int count = huodongbaomingService.selectCount(wrapper);
return R.ok().put("count", count);
}
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 添加字段名到参数
map.put("type", type); // 添加提醒类型到参数
if (type.equals("2")) { // 如果是相对日期提醒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有提醒开始时间
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
}
if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
}
}
Wrapper<HuodongbaomingEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
String tableName = request.getSession().getAttribute("tableName").toString(); // 获取当前用户表名
if (tableName.equals("zhiyuanzhe")) { // 如果是志愿者表
wrapper.eq("xuehao", (String) request.getSession().getAttribute("username")); // 设置学号条件
}
int count = huodongbaomingService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回提醒结果
}
}

@ -38,180 +38,194 @@ import com.utils.CommonUtil;
import java.io.IOException;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/huodongleixing")
public class HuodongleixingController {
@Autowired
private HuodongleixingService huodongleixingService;
private HuodongleixingService huodongleixingService; // 注入活动类型服务
/**
*
* @param params
* @param huodongleixing
* @param request HTTP
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,HuodongleixingEntity huodongleixing,
HttpServletRequest request){
EntityWrapper<HuodongleixingEntity> ew = new EntityWrapper<HuodongleixingEntity>();
PageUtils page = huodongleixingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongleixing), params), params));
public R page(@RequestParam Map<String, Object> params, HuodongleixingEntity huodongleixing,
HttpServletRequest request) {
EntityWrapper<HuodongleixingEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongleixingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongleixing), params), params));
return R.ok().put("data", page);
return R.ok().put("data", page); // 返回分页数据
}
/**
*
* @param params
* @param huodongleixing
* @param request HTTP
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,HuodongleixingEntity huodongleixing,
HttpServletRequest request){
EntityWrapper<HuodongleixingEntity> ew = new EntityWrapper<HuodongleixingEntity>();
PageUtils page = huodongleixingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongleixing), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, HuodongleixingEntity huodongleixing,
HttpServletRequest request) {
EntityWrapper<HuodongleixingEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongleixingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongleixing), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
/**
*
* @param huodongleixing
* @return
*/
@RequestMapping("/lists")
public R list( HuodongleixingEntity huodongleixing){
EntityWrapper<HuodongleixingEntity> ew = new EntityWrapper<HuodongleixingEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongleixing, "huodongleixing"));
return R.ok().put("data", huodongleixingService.selectListView(ew));
public R list(HuodongleixingEntity huodongleixing) {
EntityWrapper<HuodongleixingEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongleixing, "huodongleixing")); // 设置查询条件
return R.ok().put("data", huodongleixingService.selectListView(ew)); // 返回数据列表
}
/**
*
/**
*
* @param huodongleixing
* @return
*/
@RequestMapping("/query")
public R query(HuodongleixingEntity huodongleixing){
EntityWrapper< HuodongleixingEntity> ew = new EntityWrapper< HuodongleixingEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongleixing, "huodongleixing"));
HuodongleixingView huodongleixingView = huodongleixingService.selectView(ew);
return R.ok("查询活动类型成功").put("data", huodongleixingView);
public R query(HuodongleixingEntity huodongleixing) {
EntityWrapper<HuodongleixingEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongleixing, "huodongleixing")); // 设置查询条件
HuodongleixingView huodongleixingView = huodongleixingService.selectView(ew); // 查询视图
return R.ok("查询活动类型成功").put("data", huodongleixingView); // 返回查询结果
}
/**
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
HuodongleixingEntity huodongleixing = huodongleixingService.selectById(id);
return R.ok().put("data", huodongleixing);
public R info(@PathVariable("id") Long id) {
HuodongleixingEntity huodongleixing = huodongleixingService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongleixing); // 返回记录详情
}
/**
*
* @param id ID
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
HuodongleixingEntity huodongleixing = huodongleixingService.selectById(id);
return R.ok().put("data", huodongleixing);
public R detail(@PathVariable("id") Long id) {
HuodongleixingEntity huodongleixing = huodongleixingService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongleixing); // 返回记录详情
}
/**
*
* @param huodongleixing
* @param request HTTP
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody HuodongleixingEntity huodongleixing, HttpServletRequest request){
huodongleixing.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongleixing);
huodongleixingService.insert(huodongleixing);
return R.ok();
public R save(@RequestBody HuodongleixingEntity huodongleixing, HttpServletRequest request) {
huodongleixing.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
huodongleixingService.insert(huodongleixing); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
* @param huodongleixing
* @param request HTTP
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody HuodongleixingEntity huodongleixing, HttpServletRequest request){
huodongleixing.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongleixing);
huodongleixingService.insert(huodongleixing);
return R.ok();
public R add(@RequestBody HuodongleixingEntity huodongleixing, HttpServletRequest request) {
huodongleixing.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
huodongleixingService.insert(huodongleixing); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param huodongleixing
* @param request HTTP
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody HuodongleixingEntity huodongleixing, HttpServletRequest request){
//ValidatorUtils.validateEntity(huodongleixing);
huodongleixingService.updateById(huodongleixing);//全部更新
return R.ok();
public R update(@RequestBody HuodongleixingEntity huodongleixing, HttpServletRequest request) {
huodongleixingService.updateById(huodongleixing); // 全量更新
return R.ok(); // 返回成功结果
}
/**
*
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
huodongleixingService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
huodongleixingService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
return R.ok(); // 返回成功结果
}
/**
*
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<HuodongleixingEntity> wrapper = new EntityWrapper<HuodongleixingEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = huodongleixingService.selectCount(wrapper);
return R.ok().put("count", count);
}
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 添加字段名到参数
map.put("type", type); // 添加提醒类型到参数
if (type.equals("2")) { // 如果是相对日期提醒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有提醒开始时间
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
}
if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
}
}
Wrapper<HuodongleixingEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
int count = huodongleixingService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回提醒结果
}
}

@ -38,188 +38,204 @@ import com.utils.CommonUtil;
import java.io.IOException;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/huodongtongzhi")
public class HuodongtongzhiController {
@Autowired
private HuodongtongzhiService huodongtongzhiService;
private HuodongtongzhiService huodongtongzhiService; // 注入活动通知服务
/**
*
* @param params
* @param huodongtongzhi
* @param request HTTP
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,HuodongtongzhiEntity huodongtongzhi,
HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("zhiyuanzhe")) {
huodongtongzhi.setXuehao((String)request.getSession().getAttribute("username"));
}
EntityWrapper<HuodongtongzhiEntity> ew = new EntityWrapper<HuodongtongzhiEntity>();
PageUtils page = huodongtongzhiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongtongzhi), params), params));
return R.ok().put("data", page);
public R page(@RequestParam Map<String, Object> params, HuodongtongzhiEntity huodongtongzhi,
HttpServletRequest request) {
String tableName = request.getSession().getAttribute("tableName").toString(); // 获取当前表名
if (tableName.equals("zhiyuanzhe")) { // 如果是志愿者表
huodongtongzhi.setXuehao((String) request.getSession().getAttribute("username")); // 设置学号
}
EntityWrapper<HuodongtongzhiEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongtongzhiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongtongzhi), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
* @param params
* @param huodongtongzhi
* @param request HTTP
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,HuodongtongzhiEntity huodongtongzhi,
HttpServletRequest request){
EntityWrapper<HuodongtongzhiEntity> ew = new EntityWrapper<HuodongtongzhiEntity>();
PageUtils page = huodongtongzhiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongtongzhi), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, HuodongtongzhiEntity huodongtongzhi,
HttpServletRequest request) {
EntityWrapper<HuodongtongzhiEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongtongzhiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongtongzhi), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
/**
*
* @param huodongtongzhi
* @return
*/
@RequestMapping("/lists")
public R list( HuodongtongzhiEntity huodongtongzhi){
EntityWrapper<HuodongtongzhiEntity> ew = new EntityWrapper<HuodongtongzhiEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongtongzhi, "huodongtongzhi"));
return R.ok().put("data", huodongtongzhiService.selectListView(ew));
public R list(HuodongtongzhiEntity huodongtongzhi) {
EntityWrapper<HuodongtongzhiEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongtongzhi, "huodongtongzhi")); // 设置查询条件
return R.ok().put("data", huodongtongzhiService.selectListView(ew)); // 返回数据列表
}
/**
*
/**
*
* @param huodongtongzhi
* @return
*/
@RequestMapping("/query")
public R query(HuodongtongzhiEntity huodongtongzhi){
EntityWrapper< HuodongtongzhiEntity> ew = new EntityWrapper< HuodongtongzhiEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongtongzhi, "huodongtongzhi"));
HuodongtongzhiView huodongtongzhiView = huodongtongzhiService.selectView(ew);
return R.ok("查询活动通知成功").put("data", huodongtongzhiView);
public R query(HuodongtongzhiEntity huodongtongzhi) {
EntityWrapper<HuodongtongzhiEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongtongzhi, "huodongtongzhi")); // 设置查询条件
HuodongtongzhiView huodongtongzhiView = huodongtongzhiService.selectView(ew); // 查询视图
return R.ok("查询活动通知成功").put("data", huodongtongzhiView); // 返回查询结果
}
/**
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
HuodongtongzhiEntity huodongtongzhi = huodongtongzhiService.selectById(id);
return R.ok().put("data", huodongtongzhi);
public R info(@PathVariable("id") Long id) {
HuodongtongzhiEntity huodongtongzhi = huodongtongzhiService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongtongzhi); // 返回记录详情
}
/**
*
* @param id ID
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
HuodongtongzhiEntity huodongtongzhi = huodongtongzhiService.selectById(id);
return R.ok().put("data", huodongtongzhi);
public R detail(@PathVariable("id") Long id) {
HuodongtongzhiEntity huodongtongzhi = huodongtongzhiService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongtongzhi); // 返回记录详情
}
/**
*
* @param huodongtongzhi
* @param request HTTP
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody HuodongtongzhiEntity huodongtongzhi, HttpServletRequest request){
huodongtongzhi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongtongzhi);
huodongtongzhiService.insert(huodongtongzhi);
return R.ok();
public R save(@RequestBody HuodongtongzhiEntity huodongtongzhi, HttpServletRequest request) {
huodongtongzhi.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
huodongtongzhiService.insert(huodongtongzhi); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
* @param huodongtongzhi
* @param request HTTP
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody HuodongtongzhiEntity huodongtongzhi, HttpServletRequest request){
huodongtongzhi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongtongzhi);
huodongtongzhiService.insert(huodongtongzhi);
return R.ok();
public R add(@RequestBody HuodongtongzhiEntity huodongtongzhi, HttpServletRequest request) {
huodongtongzhi.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
huodongtongzhiService.insert(huodongtongzhi); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param huodongtongzhi
* @param request HTTP
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody HuodongtongzhiEntity huodongtongzhi, HttpServletRequest request){
//ValidatorUtils.validateEntity(huodongtongzhi);
huodongtongzhiService.updateById(huodongtongzhi);//全部更新
return R.ok();
public R update(@RequestBody HuodongtongzhiEntity huodongtongzhi, HttpServletRequest request) {
huodongtongzhiService.updateById(huodongtongzhi); // 全量更新
return R.ok(); // 返回成功结果
}
/**
*
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
huodongtongzhiService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
huodongtongzhiService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
return R.ok(); // 返回成功结果
}
/**
*
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<HuodongtongzhiEntity> wrapper = new EntityWrapper<HuodongtongzhiEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("zhiyuanzhe")) {
wrapper.eq("xuehao", (String)request.getSession().getAttribute("username"));
}
int count = huodongtongzhiService.selectCount(wrapper);
return R.ok().put("count", count);
}
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 添加字段名到参数
map.put("type", type); // 添加提醒类型到参数
if (type.equals("2")) { // 如果是相对日期提醒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有提醒开始时间
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
}
if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
}
}
Wrapper<HuodongtongzhiEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
String tableName = request.getSession().getAttribute("tableName").toString(); // 获取当前表名
if (tableName.equals("zhiyuanzhe")) { // 如果是志愿者表
wrapper.eq("xuehao", (String) request.getSession().getAttribute("username")); // 设置学号过滤条件
}
int count = huodongtongzhiService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回提醒结果
}
}

@ -40,189 +40,212 @@ import com.service.StoreupService;
import com.entity.StoreupEntity;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/huodongxinde")
public class HuodongxindeController {
@Autowired
private HuodongxindeService huodongxindeService;
private HuodongxindeService huodongxindeService; // 注入活动心得服务
@Autowired
private StoreupService storeupService;
private StoreupService storeupService; // 注入收藏服务
/**
*
* @param params
* @param huodongxinde
* @param request HTTP
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,HuodongxindeEntity huodongxinde,
HttpServletRequest request){
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
huodongxinde.setUserid((Long)request.getSession().getAttribute("userId"));
}
EntityWrapper<HuodongxindeEntity> ew = new EntityWrapper<HuodongxindeEntity>();
PageUtils page = huodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongxinde), params), params));
return R.ok().put("data", page);
public R page(@RequestParam Map<String, Object> params, HuodongxindeEntity huodongxinde,
HttpServletRequest request) {
// 如果不是管理员设置用户ID
if (!request.getSession().getAttribute("role").toString().equals("管理员")) {
huodongxinde.setUserid((Long) request.getSession().getAttribute("userId"));
}
EntityWrapper<HuodongxindeEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongxinde), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
* @param params
* @param huodongxinde
* @param request HTTP
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,HuodongxindeEntity huodongxinde,
HttpServletRequest request){
EntityWrapper<HuodongxindeEntity> ew = new EntityWrapper<HuodongxindeEntity>();
PageUtils page = huodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongxinde), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, HuodongxindeEntity huodongxinde,
HttpServletRequest request) {
EntityWrapper<HuodongxindeEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongxindeService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongxinde), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
/**
*
* @param huodongxinde
* @return
*/
@RequestMapping("/lists")
public R list( HuodongxindeEntity huodongxinde){
EntityWrapper<HuodongxindeEntity> ew = new EntityWrapper<HuodongxindeEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongxinde, "huodongxinde"));
return R.ok().put("data", huodongxindeService.selectListView(ew));
public R list(HuodongxindeEntity huodongxinde) {
EntityWrapper<HuodongxindeEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongxinde, "huodongxinde")); // 设置查询条件
return R.ok().put("data", huodongxindeService.selectListView(ew)); // 返回数据列表
}
/**
*
/**
*
* @param huodongxinde
* @return
*/
@RequestMapping("/query")
public R query(HuodongxindeEntity huodongxinde){
EntityWrapper< HuodongxindeEntity> ew = new EntityWrapper< HuodongxindeEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongxinde, "huodongxinde"));
HuodongxindeView huodongxindeView = huodongxindeService.selectView(ew);
return R.ok("查询活动心得成功").put("data", huodongxindeView);
public R query(HuodongxindeEntity huodongxinde) {
EntityWrapper<HuodongxindeEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongxinde, "huodongxinde")); // 设置查询条件
HuodongxindeView huodongxindeView = huodongxindeService.selectView(ew); // 查询视图
return R.ok("查询活动心得成功").put("data", huodongxindeView); // 返回查询结果
}
/**
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
HuodongxindeEntity huodongxinde = huodongxindeService.selectById(id);
return R.ok().put("data", huodongxinde);
public R info(@PathVariable("id") Long id) {
HuodongxindeEntity huodongxinde = huodongxindeService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongxinde); // 返回记录详情
}
/**
*
* @param id ID
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
HuodongxindeEntity huodongxinde = huodongxindeService.selectById(id);
return R.ok().put("data", huodongxinde);
public R detail(@PathVariable("id") Long id) {
HuodongxindeEntity huodongxinde = huodongxindeService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongxinde); // 返回记录详情
}
/**
*
* @param huodongxinde
* @param request HTTP
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody HuodongxindeEntity huodongxinde, HttpServletRequest request){
huodongxinde.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongxinde);
huodongxinde.setUserid((Long)request.getSession().getAttribute("userId"));
huodongxindeService.insert(huodongxinde);
return R.ok();
public R save(@RequestBody HuodongxindeEntity huodongxinde, HttpServletRequest request) {
huodongxinde.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(huodongxinde); // 验证实体(可选)
huodongxinde.setUserid((Long) request.getSession().getAttribute("userId")); // 设置用户ID
huodongxindeService.insert(huodongxinde); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
* @param huodongxinde
* @param request HTTP
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody HuodongxindeEntity huodongxinde, HttpServletRequest request){
huodongxinde.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongxinde);
huodongxindeService.insert(huodongxinde);
return R.ok();
public R add(@RequestBody HuodongxindeEntity huodongxinde, HttpServletRequest request) {
huodongxinde.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(huodongxinde); // 验证实体(可选)
huodongxinde.setUserid((Long) request.getSession().getAttribute("userId")); // 设置用户ID
huodongxindeService.insert(huodongxinde); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param huodongxinde
* @param request HTTP
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody HuodongxindeEntity huodongxinde, HttpServletRequest request){
//ValidatorUtils.validateEntity(huodongxinde);
huodongxindeService.updateById(huodongxinde);//全部更新
return R.ok();
public R update(@RequestBody HuodongxindeEntity huodongxinde, HttpServletRequest request) {
// ValidatorUtils.validateEntity(huodongxinde); // 验证实体(可选)
huodongxindeService.updateById(huodongxinde); // 全量更新
return R.ok(); // 返回成功结果
}
/**
*
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
huodongxindeService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
huodongxindeService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
return R.ok(); // 返回成功结果
}
/**
*
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<HuodongxindeEntity> wrapper = new EntityWrapper<HuodongxindeEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
wrapper.eq("userid", (Long)request.getSession().getAttribute("userId"));
}
int count = huodongxindeService.selectCount(wrapper);
return R.ok().put("count", count);
}
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 添加字段名到参数
map.put("type", type); // 添加提醒类型到参数
if (type.equals("2")) { // 如果是相对日期提醒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有提醒开始时间
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
}
if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
}
}
Wrapper<HuodongxindeEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
// 如果不是管理员设置用户ID过滤条件
if (!request.getSession().getAttribute("role").toString().equals("管理员")) {
wrapper.eq("userid", (Long) request.getSession().getAttribute("userId"));
}
int count = huodongxindeService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回提醒结果
}
}

@ -38,180 +38,197 @@ import com.utils.CommonUtil;
import java.io.IOException;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/huodongxinxi")
public class HuodongxinxiController {
@Autowired
private HuodongxinxiService huodongxinxiService;
private HuodongxinxiService huodongxinxiService; // 注入活动信息服务
/**
*
* @param params
* @param huodongxinxi
* @param request HTTP
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,HuodongxinxiEntity huodongxinxi,
HttpServletRequest request){
EntityWrapper<HuodongxinxiEntity> ew = new EntityWrapper<HuodongxinxiEntity>();
PageUtils page = huodongxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongxinxi), params), params));
public R page(@RequestParam Map<String, Object> params, HuodongxinxiEntity huodongxinxi,
HttpServletRequest request) {
EntityWrapper<HuodongxinxiEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongxinxi), params), params));
return R.ok().put("data", page);
return R.ok().put("data", page); // 返回分页数据
}
/**
*
* @param params
* @param huodongxinxi
* @param request HTTP
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,HuodongxinxiEntity huodongxinxi,
HttpServletRequest request){
EntityWrapper<HuodongxinxiEntity> ew = new EntityWrapper<HuodongxinxiEntity>();
PageUtils page = huodongxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongxinxi), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, HuodongxinxiEntity huodongxinxi,
HttpServletRequest request) {
EntityWrapper<HuodongxinxiEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongxinxi), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
/**
*
* @param huodongxinxi
* @return
*/
@RequestMapping("/lists")
public R list( HuodongxinxiEntity huodongxinxi){
EntityWrapper<HuodongxinxiEntity> ew = new EntityWrapper<HuodongxinxiEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongxinxi, "huodongxinxi"));
return R.ok().put("data", huodongxinxiService.selectListView(ew));
public R list(HuodongxinxiEntity huodongxinxi) {
EntityWrapper<HuodongxinxiEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongxinxi, "huodongxinxi")); // 设置查询条件
return R.ok().put("data", huodongxinxiService.selectListView(ew)); // 返回数据列表
}
/**
*
/**
*
* @param huodongxinxi
* @return
*/
@RequestMapping("/query")
public R query(HuodongxinxiEntity huodongxinxi){
EntityWrapper< HuodongxinxiEntity> ew = new EntityWrapper< HuodongxinxiEntity>();
ew.allEq(MPUtil.allEQMapPre( huodongxinxi, "huodongxinxi"));
HuodongxinxiView huodongxinxiView = huodongxinxiService.selectView(ew);
return R.ok("查询活动信息成功").put("data", huodongxinxiView);
public R query(HuodongxinxiEntity huodongxinxi) {
EntityWrapper<HuodongxinxiEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(huodongxinxi, "huodongxinxi")); // 设置查询条件
HuodongxinxiView huodongxinxiView = huodongxinxiService.selectView(ew); // 查询视图
return R.ok("查询活动信息成功").put("data", huodongxinxiView); // 返回查询结果
}
/**
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
HuodongxinxiEntity huodongxinxi = huodongxinxiService.selectById(id);
return R.ok().put("data", huodongxinxi);
public R info(@PathVariable("id") Long id) {
HuodongxinxiEntity huodongxinxi = huodongxinxiService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongxinxi); // 返回记录详情
}
/**
*
* @param id ID
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
HuodongxinxiEntity huodongxinxi = huodongxinxiService.selectById(id);
return R.ok().put("data", huodongxinxi);
public R detail(@PathVariable("id") Long id) {
HuodongxinxiEntity huodongxinxi = huodongxinxiService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongxinxi); // 返回记录详情
}
/**
*
* @param huodongxinxi
* @param request HTTP
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody HuodongxinxiEntity huodongxinxi, HttpServletRequest request){
huodongxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongxinxi);
huodongxinxiService.insert(huodongxinxi);
return R.ok();
public R save(@RequestBody HuodongxinxiEntity huodongxinxi, HttpServletRequest request) {
huodongxinxi.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(huodongxinxi); // 验证实体(可选)
huodongxinxiService.insert(huodongxinxi); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
* @param huodongxinxi
* @param request HTTP
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody HuodongxinxiEntity huodongxinxi, HttpServletRequest request){
huodongxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huodongxinxi);
huodongxinxiService.insert(huodongxinxi);
return R.ok();
public R add(@RequestBody HuodongxinxiEntity huodongxinxi, HttpServletRequest request) {
huodongxinxi.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(huodongxinxi); // 验证实体(可选)
huodongxinxiService.insert(huodongxinxi); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param huodongxinxi
* @param request HTTP
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody HuodongxinxiEntity huodongxinxi, HttpServletRequest request){
//ValidatorUtils.validateEntity(huodongxinxi);
huodongxinxiService.updateById(huodongxinxi);//全部更新
return R.ok();
public R update(@RequestBody HuodongxinxiEntity huodongxinxi, HttpServletRequest request) {
// ValidatorUtils.validateEntity(huodongxinxi); // 验证实体(可选)
huodongxinxiService.updateById(huodongxinxi); // 全量更新
return R.ok(); // 返回成功结果
}
/**
*
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
huodongxinxiService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
huodongxinxiService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
return R.ok(); // 返回成功结果
}
/**
*
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<HuodongxinxiEntity> wrapper = new EntityWrapper<HuodongxinxiEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = huodongxinxiService.selectCount(wrapper);
return R.ok().put("count", count);
}
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 添加字段名到参数
map.put("type", type); // 添加提醒类型到参数
if (type.equals("2")) { // 如果是相对日期提醒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有提醒开始时间
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
}
if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
}
}
Wrapper<HuodongxinxiEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
int count = huodongxinxiService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回提醒结果
}
}

@ -38,183 +38,200 @@ import com.utils.CommonUtil;
import java.io.IOException;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/messages")
public class MessagesController {
@Autowired
private MessagesService messagesService;
private MessagesService messagesService; // 注入消息服务
/**
*
* @param params
* @param messages
* @param request HTTP
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,MessagesEntity messages,
HttpServletRequest request){
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
messages.setUserid((Long)request.getSession().getAttribute("userId"));
}
EntityWrapper<MessagesEntity> ew = new EntityWrapper<MessagesEntity>();
PageUtils page = messagesService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, messages), params), params));
return R.ok().put("data", page);
public R page(@RequestParam Map<String, Object> params, MessagesEntity messages,
HttpServletRequest request) {
if (!request.getSession().getAttribute("role").toString().equals("管理员")) {
messages.setUserid((Long) request.getSession().getAttribute("userId")); // 设置当前用户ID
}
EntityWrapper<MessagesEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = messagesService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, messages), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
* @param params
* @param messages
* @param request HTTP
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,MessagesEntity messages,
HttpServletRequest request){
EntityWrapper<MessagesEntity> ew = new EntityWrapper<MessagesEntity>();
PageUtils page = messagesService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, messages), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, MessagesEntity messages,
HttpServletRequest request) {
EntityWrapper<MessagesEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = messagesService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, messages), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
/**
*
* @param messages
* @return
*/
@RequestMapping("/lists")
public R list( MessagesEntity messages){
EntityWrapper<MessagesEntity> ew = new EntityWrapper<MessagesEntity>();
ew.allEq(MPUtil.allEQMapPre( messages, "messages"));
return R.ok().put("data", messagesService.selectListView(ew));
public R list(MessagesEntity messages) {
EntityWrapper<MessagesEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(messages, "messages")); // 设置查询条件
return R.ok().put("data", messagesService.selectListView(ew)); // 返回数据列表
}
/**
*
/**
*
* @param messages
* @return
*/
@RequestMapping("/query")
public R query(MessagesEntity messages){
EntityWrapper< MessagesEntity> ew = new EntityWrapper< MessagesEntity>();
ew.allEq(MPUtil.allEQMapPre( messages, "messages"));
MessagesView messagesView = messagesService.selectView(ew);
return R.ok("查询交流反馈成功").put("data", messagesView);
public R query(MessagesEntity messages) {
EntityWrapper<MessagesEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(messages, "messages")); // 设置查询条件
MessagesView messagesView = messagesService.selectView(ew); // 查询视图
return R.ok("查询交流反馈成功").put("data", messagesView); // 返回查询结果
}
/**
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
MessagesEntity messages = messagesService.selectById(id);
return R.ok().put("data", messages);
public R info(@PathVariable("id") Long id) {
MessagesEntity messages = messagesService.selectById(id); // 查询单条记录
return R.ok().put("data", messages); // 返回记录详情
}
/**
*
* @param id ID
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
MessagesEntity messages = messagesService.selectById(id);
return R.ok().put("data", messages);
public R detail(@PathVariable("id") Long id) {
MessagesEntity messages = messagesService.selectById(id); // 查询单条记录
return R.ok().put("data", messages); // 返回记录详情
}
/**
*
* @param messages
* @param request HTTP
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody MessagesEntity messages, HttpServletRequest request){
messages.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(messages);
messagesService.insert(messages);
return R.ok();
public R save(@RequestBody MessagesEntity messages, HttpServletRequest request) {
messages.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(messages); // 验证实体(可选)
messagesService.insert(messages); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
* @param messages
* @param request HTTP
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody MessagesEntity messages, HttpServletRequest request){
messages.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(messages);
messagesService.insert(messages);
return R.ok();
public R add(@RequestBody MessagesEntity messages, HttpServletRequest request) {
messages.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(messages); // 验证实体(可选)
messagesService.insert(messages); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param messages
* @param request HTTP
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody MessagesEntity messages, HttpServletRequest request){
//ValidatorUtils.validateEntity(messages);
messagesService.updateById(messages);//全部更新
return R.ok();
public R update(@RequestBody MessagesEntity messages, HttpServletRequest request) {
// ValidatorUtils.validateEntity(messages); // 验证实体(可选)
messagesService.updateById(messages); // 全量更新
return R.ok(); // 返回成功结果
}
/**
*
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
messagesService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
messagesService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
return R.ok(); // 返回成功结果
}
/**
*
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<MessagesEntity> wrapper = new EntityWrapper<MessagesEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = messagesService.selectCount(wrapper);
return R.ok().put("count", count);
}
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 添加字段名到参数
map.put("type", type); // 添加提醒类型到参数
if (type.equals("2")) { // 如果是相对日期提醒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有提醒开始时间
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
}
if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
}
}
Wrapper<MessagesEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
int count = messagesService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回提醒结果
}
}

@ -38,180 +38,197 @@ import com.utils.CommonUtil;
import java.io.IOException;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/news")
public class NewsController {
@Autowired
private NewsService newsService;
private NewsService newsService; // 注入新闻服务
/**
*
* @param params
* @param news
* @param request HTTP
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,NewsEntity news,
HttpServletRequest request){
EntityWrapper<NewsEntity> ew = new EntityWrapper<NewsEntity>();
PageUtils page = newsService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, news), params), params));
public R page(@RequestParam Map<String, Object> params, NewsEntity news,
HttpServletRequest request) {
EntityWrapper<NewsEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = newsService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, news), params), params));
return R.ok().put("data", page);
return R.ok().put("data", page); // 返回分页数据
}
/**
*
* @param params
* @param news
* @param request HTTP
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,NewsEntity news,
HttpServletRequest request){
EntityWrapper<NewsEntity> ew = new EntityWrapper<NewsEntity>();
PageUtils page = newsService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, news), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, NewsEntity news,
HttpServletRequest request) {
EntityWrapper<NewsEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = newsService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, news), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
/**
*
* @param news
* @return
*/
@RequestMapping("/lists")
public R list( NewsEntity news){
EntityWrapper<NewsEntity> ew = new EntityWrapper<NewsEntity>();
ew.allEq(MPUtil.allEQMapPre( news, "news"));
return R.ok().put("data", newsService.selectListView(ew));
public R list(NewsEntity news) {
EntityWrapper<NewsEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(news, "news")); // 设置查询条件
return R.ok().put("data", newsService.selectListView(ew)); // 返回数据列表
}
/**
*
/**
*
* @param news
* @return
*/
@RequestMapping("/query")
public R query(NewsEntity news){
EntityWrapper< NewsEntity> ew = new EntityWrapper< NewsEntity>();
ew.allEq(MPUtil.allEQMapPre( news, "news"));
NewsView newsView = newsService.selectView(ew);
return R.ok("查询公告信息成功").put("data", newsView);
public R query(NewsEntity news) {
EntityWrapper<NewsEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(news, "news")); // 设置查询条件
NewsView newsView = newsService.selectView(ew); // 查询视图
return R.ok("查询公告信息成功").put("data", newsView); // 返回查询结果
}
/**
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
NewsEntity news = newsService.selectById(id);
return R.ok().put("data", news);
public R info(@PathVariable("id") Long id) {
NewsEntity news = newsService.selectById(id); // 查询单条记录
return R.ok().put("data", news); // 返回记录详情
}
/**
*
* @param id ID
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
NewsEntity news = newsService.selectById(id);
return R.ok().put("data", news);
public R detail(@PathVariable("id") Long id) {
NewsEntity news = newsService.selectById(id); // 查询单条记录
return R.ok().put("data", news); // 返回记录详情
}
/**
*
* @param news
* @param request HTTP
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody NewsEntity news, HttpServletRequest request){
news.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(news);
newsService.insert(news);
return R.ok();
public R save(@RequestBody NewsEntity news, HttpServletRequest request) {
news.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(news); // 验证实体(可选)
newsService.insert(news); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
* @param news
* @param request HTTP
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody NewsEntity news, HttpServletRequest request){
news.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(news);
newsService.insert(news);
return R.ok();
public R add(@RequestBody NewsEntity news, HttpServletRequest request) {
news.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(news); // 验证实体(可选)
newsService.insert(news); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param news
* @param request HTTP
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody NewsEntity news, HttpServletRequest request){
//ValidatorUtils.validateEntity(news);
newsService.updateById(news);//全部更新
return R.ok();
public R update(@RequestBody NewsEntity news, HttpServletRequest request) {
// ValidatorUtils.validateEntity(news); // 验证实体(可选)
newsService.updateById(news); // 全量更新
return R.ok(); // 返回成功结果
}
/**
*
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
newsService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
newsService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
return R.ok(); // 返回成功结果
}
/**
*
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<NewsEntity> wrapper = new EntityWrapper<NewsEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = newsService.selectCount(wrapper);
return R.ok().put("count", count);
}
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 添加字段名到参数
map.put("type", type); // 添加提醒类型到参数
if (type.equals("2")) { // 如果是相对日期提醒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有提醒开始时间
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
}
if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
}
}
Wrapper<NewsEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
int count = newsService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回提醒结果
}
}

@ -38,190 +38,207 @@ import com.utils.CommonUtil;
import java.io.IOException;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/storeup")
public class StoreupController {
@Autowired
private StoreupService storeupService;
private StoreupService storeupService; // 注入收藏服务
/**
*
* @param params
* @param storeup
* @param request HTTP
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,StoreupEntity storeup,
HttpServletRequest request){
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
storeup.setUserid((Long)request.getSession().getAttribute("userId"));
}
EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>();
PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params));
return R.ok().put("data", page);
public R page(@RequestParam Map<String, Object> params, StoreupEntity storeup,
HttpServletRequest request) {
if (!request.getSession().getAttribute("role").toString().equals("管理员")) {
storeup.setUserid((Long) request.getSession().getAttribute("userId")); // 非管理员设置用户ID
}
EntityWrapper<StoreupEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
* @param params
* @param storeup
* @param request HTTP
* @return
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,StoreupEntity storeup,
HttpServletRequest request){
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
storeup.setUserid((Long)request.getSession().getAttribute("userId"));
}
EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>();
PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params));
return R.ok().put("data", page);
public R list(@RequestParam Map<String, Object> params, StoreupEntity storeup,
HttpServletRequest request) {
if (!request.getSession().getAttribute("role").toString().equals("管理员")) {
storeup.setUserid((Long) request.getSession().getAttribute("userId")); // 非管理员设置用户ID
}
EntityWrapper<StoreupEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params));
return R.ok().put("data", page); // 返回分页数据
}
/**
*
/**
*
* @param storeup
* @return
*/
@RequestMapping("/lists")
public R list( StoreupEntity storeup){
EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>();
ew.allEq(MPUtil.allEQMapPre( storeup, "storeup"));
return R.ok().put("data", storeupService.selectListView(ew));
public R list(StoreupEntity storeup) {
EntityWrapper<StoreupEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(storeup, "storeup")); // 设置查询条件
return R.ok().put("data", storeupService.selectListView(ew)); // 返回数据列表
}
/**
*
/**
*
* @param storeup
* @return
*/
@RequestMapping("/query")
public R query(StoreupEntity storeup){
EntityWrapper< StoreupEntity> ew = new EntityWrapper< StoreupEntity>();
ew.allEq(MPUtil.allEQMapPre( storeup, "storeup"));
StoreupView storeupView = storeupService.selectView(ew);
return R.ok("查询收藏表成功").put("data", storeupView);
public R query(StoreupEntity storeup) {
EntityWrapper<StoreupEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(storeup, "storeup")); // 设置查询条件
StoreupView storeupView = storeupService.selectView(ew); // 查询视图
return R.ok("查询收藏表成功").put("data", storeupView); // 返回查询结果
}
/**
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
StoreupEntity storeup = storeupService.selectById(id);
return R.ok().put("data", storeup);
public R info(@PathVariable("id") Long id) {
StoreupEntity storeup = storeupService.selectById(id); // 查询单条记录
return R.ok().put("data", storeup); // 返回记录详情
}
/**
*
* @param id ID
* @return
*/
@IgnoreAuth
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
StoreupEntity storeup = storeupService.selectById(id);
return R.ok().put("data", storeup);
public R detail(@PathVariable("id") Long id) {
StoreupEntity storeup = storeupService.selectById(id); // 查询单条记录
return R.ok().put("data", storeup); // 返回记录详情
}
/**
*
* @param storeup
* @param request HTTP
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody StoreupEntity storeup, HttpServletRequest request){
storeup.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(storeup);
storeup.setUserid((Long)request.getSession().getAttribute("userId"));
storeupService.insert(storeup);
return R.ok();
public R save(@RequestBody StoreupEntity storeup, HttpServletRequest request) {
storeup.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(storeup); // 验证实体(可选)
storeup.setUserid((Long) request.getSession().getAttribute("userId")); // 设置用户ID
storeupService.insert(storeup); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
* @param storeup
* @param request HTTP
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody StoreupEntity storeup, HttpServletRequest request){
storeup.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(storeup);
storeup.setUserid((Long)request.getSession().getAttribute("userId"));
storeupService.insert(storeup);
return R.ok();
public R add(@RequestBody StoreupEntity storeup, HttpServletRequest request) {
storeup.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(storeup); // 验证实体(可选)
storeup.setUserid((Long) request.getSession().getAttribute("userId")); // 设置用户ID
storeupService.insert(storeup); // 插入数据
return R.ok(); // 返回成功结果
}
/**
*
*
* @param storeup
* @param request HTTP
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody StoreupEntity storeup, HttpServletRequest request){
//ValidatorUtils.validateEntity(storeup);
storeupService.updateById(storeup);//全部更新
return R.ok();
public R update(@RequestBody StoreupEntity storeup, HttpServletRequest request) {
// ValidatorUtils.validateEntity(storeup); // 验证实体(可选)
storeupService.updateById(storeup); // 全量更新
return R.ok(); // 返回成功结果
}
/**
*
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
storeupService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
public R delete(@RequestBody Long[] ids) {
storeupService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
return R.ok(); // 返回成功结果
}
/**
*
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<StoreupEntity> wrapper = new EntityWrapper<StoreupEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
wrapper.eq("userid", (Long)request.getSession().getAttribute("userId"));
}
int count = storeupService.selectCount(wrapper);
return R.ok().put("count", count);
}
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 添加字段名到参数
map.put("type", type); // 添加提醒类型到参数
if (type.equals("2")) { // 如果是相对日期提醒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有提醒开始时间
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
}
if (map.get("remindend") != null) { // 如果有提醒结束时间
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
}
}
Wrapper<StoreupEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
if (!request.getSession().getAttribute("role").toString().equals("管理员")) {
wrapper.eq("userid", (Long) request.getSession().getAttribute("userId")); // 非管理员过滤数据
}
int count = storeupService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回提醒结果
}
}

@ -1,7 +1,5 @@
package com.controller;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
@ -33,142 +31,169 @@ import com.utils.R;
import com.utils.ValidatorUtils;
/**
*
*
*/
@RequestMapping("users")
@RestController
public class UserController{
public class UserController {
@Autowired
private UserService userService;
private UserService userService; // 注入用户服务
@Autowired
private TokenService tokenService;
private TokenService tokenService; // 注入令牌服务
/**
*
*
* @param username
* @param password
* @param captcha 使
* @param request HTTP
* @return
*/
@IgnoreAuth
@PostMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
if(user==null || !user.getPassword().equals(password)) {
return R.error("账号或密码不正确");
UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username)); // 查询用户
if (user == null || !user.getPassword().equals(password)) { // 验证用户名和密码是否匹配
return R.error("账号或密码不正确"); // 返回错误信息
}
String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
return R.ok().put("token", token);
String token = tokenService.generateToken(user.getId(), username, "users", user.getRole()); // 生成令牌
return R.ok().put("token", token); // 返回成功结果及令牌
}
/**
*
*
* @param user
* @return
*/
@IgnoreAuth
@PostMapping(value = "/register")
public R register(@RequestBody UserEntity user){
// ValidatorUtils.validateEntity(user);
if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
return R.error("用户已存在");
}
userService.insert(user);
return R.ok();
}
public R register(@RequestBody UserEntity user) {
// ValidatorUtils.validateEntity(user); // 验证用户实体(可选)
if (userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) != null) { // 检查用户名是否已存在
return R.error("用户已存在"); // 返回错误信息
}
userService.insert(user); // 插入新用户
return R.ok(); // 返回成功结果
}
/**
* 退
* 退
* @param request HTTP
* @return 退
*/
@GetMapping(value = "logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
request.getSession().invalidate(); // 清空Session
return R.ok("退出成功"); // 返回成功信息
}
/**
*
*/
@IgnoreAuth
*
* @param username
* @param request HTTP
* @return
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
if(user==null) {
return R.error("账号不存在");
}
user.setPassword("123456");
userService.update(user,null);
return R.ok("密码已重置为123456");
}
public R resetPass(String username, HttpServletRequest request) {
UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username)); // 查询用户
if (user == null) { // 如果用户不存在
return R.error("账号不存在"); // 返回错误信息
}
user.setPassword("123456"); // 设置默认密码
userService.update(user, null); // 更新用户密码
return R.ok("密码已重置为123456"); // 返回成功信息
}
/**
*
* @param params
* @param user
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, UserEntity user) {
EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>(); // 创建查询条件
PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params)); // 查询分页数据
return R.ok().put("data", page); // 返回分页数据
}
/**
*
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,UserEntity user){
EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
return R.ok().put("data", page);
}
*
* @param user
* @return
*/
@RequestMapping("/list")
public R list(UserEntity user) {
EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>(); // 创建查询条件
ew.allEq(MPUtil.allEQMapPre(user, "user")); // 设置查询条件
return R.ok().put("data", userService.selectListView(ew)); // 返回用户列表
}
/**
*
*/
@RequestMapping("/list")
public R list( UserEntity user){
EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
ew.allEq(MPUtil.allEQMapPre( user, "user"));
return R.ok().put("data", userService.selectListView(ew));
}
/**
*
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id){
UserEntity user = userService.selectById(id);
return R.ok().put("data", user);
}
/**
* session
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Long id = (Long)request.getSession().getAttribute("userId");
UserEntity user = userService.selectById(id);
return R.ok().put("data", user);
}
/**
*
*/
@PostMapping("/save")
public R save(@RequestBody UserEntity user){
// ValidatorUtils.validateEntity(user);
if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
return R.error("用户已存在");
}
userService.insert(user);
return R.ok();
}
/**
*
*/
@RequestMapping("/update")
public R update(@RequestBody UserEntity user){
// ValidatorUtils.validateEntity(user);
UserEntity u = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername()));
if(u!=null && u.getId()!=user.getId() && u.getUsername().equals(user.getUsername())) {
return R.error("用户名已存在。");
}
userService.updateById(user);//全部更新
return R.ok();
}
/**
*
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
userService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id) {
UserEntity user = userService.selectById(id); // 查询用户信息
return R.ok().put("data", user); // 返回用户信息
}
/**
* Session
* @param request HTTP
* @return
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request) {
Long id = (Long) request.getSession().getAttribute("userId"); // 获取Session中的用户ID
UserEntity user = userService.selectById(id); // 查询用户信息
return R.ok().put("data", user); // 返回当前用户信息
}
/**
*
* @param user
* @return
*/
@PostMapping("/save")
public R save(@RequestBody UserEntity user) {
// ValidatorUtils.validateEntity(user); // 验证用户实体(可选)
if (userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) != null) { // 检查用户名是否已存在
return R.error("用户已存在"); // 返回错误信息
}
userService.insert(user); // 插入新用户
return R.ok(); // 返回成功结果
}
/**
*
* @param user
* @return
*/
@RequestMapping("/update")
public R update(@RequestBody UserEntity user) {
// ValidatorUtils.validateEntity(user); // 验证用户实体(可选)
UserEntity u = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())); // 查询用户名是否存在
if (u != null && u.getId() != user.getId() && u.getUsername().equals(user.getUsername())) { // 检查用户名是否重复
return R.error("用户名已存在。"); // 返回错误信息
}
userService.updateById(user); // 全量更新用户信息
return R.ok(); // 返回成功结果
}
/**
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids) {
userService.deleteBatchIds(Arrays.asList(ids)); // 批量删除用户
return R.ok(); // 返回成功结果
}
}

@ -4,294 +4,314 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.format.annotation.DateTimeFormat;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
import com.entity.ZhiyuanzheEntity;
import com.entity.view.ZhiyuanzheView;
import com.service.ZhiyuanzheService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
import java.io.IOException;
import com.utils.PageUtils;
import com.utils.R;
/**
*
*
* @author
* @email
*
* @author []
* @email []
* @date 2022-05-06 08:33:49
*/
@RestController
@RequestMapping("/zhiyuanzhe")
public class ZhiyuanzheController {
@Autowired
private ZhiyuanzheService zhiyuanzheService;
@Autowired
private ZhiyuanzheService zhiyuanzheService; // 注入志愿者服务
@Autowired
private TokenService tokenService;
private TokenService tokenService; // 注入令牌服务
/**
*
*
* @param username
* @param password
* @param captcha 使
* @param request HTTP
* @return
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", username));
if(user==null || !user.getMima().equals(password)) {
return R.error("账号或密码不正确");
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", username)); // 查询用户
if (user == null || !user.getMima().equals(password)) { // 验证用户名和密码是否匹配
return R.error("账号或密码不正确"); // 返回错误信息
}
if ("否".equals(user.getSfsh())) { // 检查账号是否被锁定
return R.error("账号已锁定,请联系管理员审核。");
}
if("否".equals(user.getSfsh())) return R.error("账号已锁定,请联系管理员审核。");
String token = tokenService.generateToken(user.getId(), username,"zhiyuanzhe", "志愿者" );
return R.ok().put("token", token);
String token = tokenService.generateToken(user.getId(), username, "zhiyuanzhe", "志愿者"); // 生成令牌
return R.ok().put("token", token); // 返回成功结果及令牌
}
/**
*
*/
*
* @param zhiyuanzhe
* @return
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody ZhiyuanzheEntity zhiyuanzhe){
//ValidatorUtils.validateEntity(zhiyuanzhe);
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", zhiyuanzhe.getXuehao()));
if(user!=null) {
return R.error("注册用户已存在");
@RequestMapping("/register")
public R register(@RequestBody ZhiyuanzheEntity zhiyuanzhe) {
// ValidatorUtils.validateEntity(zhiyuanzhe); // 验证用户实体(可选)
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", zhiyuanzhe.getXuehao())); // 检查用户名是否已存在
if (user != null) {
return R.error("注册用户已存在"); // 返回错误信息
}
Long uId = new Date().getTime();
zhiyuanzhe.setId(uId);
zhiyuanzheService.insert(zhiyuanzhe);
return R.ok();
}
Long uId = new Date().getTime(); // 生成唯一ID
zhiyuanzhe.setId(uId); // 设置用户ID
zhiyuanzheService.insert(zhiyuanzhe); // 插入新用户
return R.ok(); // 返回成功结果
}
/**
* 退
* 退
* @param request HTTP
* @return 退
*/
@RequestMapping("/logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
request.getSession().invalidate(); // 清空Session
return R.ok("退出成功"); // 返回成功信息
}
/**
* session
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Long id = (Long)request.getSession().getAttribute("userId");
ZhiyuanzheEntity user = zhiyuanzheService.selectById(id);
return R.ok().put("data", user);
}
/**
*
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", username));
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
zhiyuanzheService.updateById(user);
return R.ok("密码已重置为123456");
}
* Session
* @param request HTTP
* @return
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request) {
Long id = (Long) request.getSession().getAttribute("userId"); // 获取Session中的用户ID
ZhiyuanzheEntity user = zhiyuanzheService.selectById(id); // 查询用户信息
return R.ok().put("data", user); // 返回当前用户信息
}
/**
*
* @param username
* @param request HTTP
* @return
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request) {
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", username)); // 查询用户
if (user == null) { // 如果用户不存在
return R.error("账号不存在"); // 返回错误信息
}
user.setMima("123456"); // 设置默认密码
zhiyuanzheService.updateById(user); // 更新用户密码
return R.ok("密码已重置为123456"); // 返回成功信息
}
/**
*
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,ZhiyuanzheEntity zhiyuanzhe,
HttpServletRequest request){
EntityWrapper<ZhiyuanzheEntity> ew = new EntityWrapper<ZhiyuanzheEntity>();
PageUtils page = zhiyuanzheService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, zhiyuanzhe), params), params));
/**
*
* @param params
* @param zhiyuanzhe
* @param request HTTP
* @return
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, ZhiyuanzheEntity zhiyuanzhe, HttpServletRequest request) {
EntityWrapper<ZhiyuanzheEntity> ew = new EntityWrapper<ZhiyuanzheEntity>(); // 创建查询条件
PageUtils page = zhiyuanzheService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, zhiyuanzhe), params), params)); // 查询分页数据
return R.ok().put("data", page); // 返回分页数据
}
return R.ok().put("data", page);
}
/**
*
*/
/**
*
* @param params
* @param zhiyuanzhe
* @param request HTTP
* @return
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,ZhiyuanzheEntity zhiyuanzhe,
HttpServletRequest request){
EntityWrapper<ZhiyuanzheEntity> ew = new EntityWrapper<ZhiyuanzheEntity>();
PageUtils page = zhiyuanzheService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, zhiyuanzhe), params), params));
return R.ok().put("data", page);
}
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, ZhiyuanzheEntity zhiyuanzhe, HttpServletRequest request) {
EntityWrapper<ZhiyuanzheEntity> ew = new EntityWrapper<ZhiyuanzheEntity>(); // 创建查询条件
PageUtils page = zhiyuanzheService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, zhiyuanzhe), params), params)); // 查询分页数据
return R.ok().put("data", page); // 返回分页数据
}
/**
*
*/
@RequestMapping("/lists")
public R list( ZhiyuanzheEntity zhiyuanzhe){
EntityWrapper<ZhiyuanzheEntity> ew = new EntityWrapper<ZhiyuanzheEntity>();
ew.allEq(MPUtil.allEQMapPre( zhiyuanzhe, "zhiyuanzhe"));
return R.ok().put("data", zhiyuanzheService.selectListView(ew));
}
/**
*
*/
@RequestMapping("/query")
public R query(ZhiyuanzheEntity zhiyuanzhe){
EntityWrapper< ZhiyuanzheEntity> ew = new EntityWrapper< ZhiyuanzheEntity>();
ew.allEq(MPUtil.allEQMapPre( zhiyuanzhe, "zhiyuanzhe"));
ZhiyuanzheView zhiyuanzheView = zhiyuanzheService.selectView(ew);
return R.ok("查询志愿者成功").put("data", zhiyuanzheView);
}
/**
*
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
ZhiyuanzheEntity zhiyuanzhe = zhiyuanzheService.selectById(id);
return R.ok().put("data", zhiyuanzhe);
}
*
* @param zhiyuanzhe
* @return
*/
@RequestMapping("/lists")
public R lists(ZhiyuanzheEntity zhiyuanzhe) {
EntityWrapper<ZhiyuanzheEntity> ew = new EntityWrapper<ZhiyuanzheEntity>(); // 创建查询条件
ew.allEq(MPUtil.allEQMapPre(zhiyuanzhe, "zhiyuanzhe")); // 设置查询条件
return R.ok().put("data", zhiyuanzheService.selectListView(ew)); // 返回用户列表
}
/**
*
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
ZhiyuanzheEntity zhiyuanzhe = zhiyuanzheService.selectById(id);
return R.ok().put("data", zhiyuanzhe);
}
/**
*
* @param zhiyuanzhe
* @return
*/
@RequestMapping("/query")
public R query(ZhiyuanzheEntity zhiyuanzhe) {
EntityWrapper<ZhiyuanzheEntity> ew = new EntityWrapper<ZhiyuanzheEntity>(); // 创建查询条件
ew.allEq(MPUtil.allEQMapPre(zhiyuanzhe, "zhiyuanzhe")); // 设置查询条件
ZhiyuanzheView zhiyuanzheView = zhiyuanzheService.selectView(ew); // 查询视图数据
return R.ok("查询志愿者成功").put("data", zhiyuanzheView); // 返回查询结果
}
/**
*
* @param id ID
* @return
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id) {
ZhiyuanzheEntity zhiyuanzhe = zhiyuanzheService.selectById(id); // 查询用户信息
return R.ok().put("data", zhiyuanzhe); // 返回用户详情
}
/**
*
* @param id ID
* @return
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id) {
ZhiyuanzheEntity zhiyuanzhe = zhiyuanzheService.selectById(id); // 查询用户信息
return R.ok().put("data", zhiyuanzhe); // 返回用户详情
}
/**
*
*/
@RequestMapping("/save")
public R save(@RequestBody ZhiyuanzheEntity zhiyuanzhe, HttpServletRequest request){
zhiyuanzhe.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(zhiyuanzhe);
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", zhiyuanzhe.getXuehao()));
if(user!=null) {
return R.error("用户已存在");
/**
*
* @param zhiyuanzhe
* @param request HTTP
* @return
*/
@RequestMapping("/save")
public R save(@RequestBody ZhiyuanzheEntity zhiyuanzhe, HttpServletRequest request) {
zhiyuanzhe.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(zhiyuanzhe); // 验证用户实体(可选)
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", zhiyuanzhe.getXuehao())); // 检查用户名是否已存在
if (user != null) {
return R.error("用户已存在"); // 返回错误信息
}
zhiyuanzhe.setId(new Date().getTime());
zhiyuanzheService.insert(zhiyuanzhe);
return R.ok();
}
/**
*
*/
@RequestMapping("/add")
public R add(@RequestBody ZhiyuanzheEntity zhiyuanzhe, HttpServletRequest request){
zhiyuanzhe.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(zhiyuanzhe);
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", zhiyuanzhe.getXuehao()));
if(user!=null) {
return R.error("用户已存在");
zhiyuanzhe.setId(new Date().getTime()); // 设置用户ID
zhiyuanzheService.insert(zhiyuanzhe); // 插入新用户
return R.ok(); // 返回成功结果
}
/**
*
* @param zhiyuanzhe
* @param request HTTP
* @return
*/
@RequestMapping("/add")
public R add(@RequestBody ZhiyuanzheEntity zhiyuanzhe, HttpServletRequest request) {
zhiyuanzhe.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
// ValidatorUtils.validateEntity(zhiyuanzhe); // 验证用户实体(可选)
ZhiyuanzheEntity user = zhiyuanzheService.selectOne(new EntityWrapper<ZhiyuanzheEntity>().eq("xuehao", zhiyuanzhe.getXuehao())); // 检查用户名是否已存在
if (user != null) {
return R.error("用户已存在"); // 返回错误信息
}
zhiyuanzhe.setId(new Date().getTime());
zhiyuanzheService.insert(zhiyuanzhe);
return R.ok();
}
zhiyuanzhe.setId(new Date().getTime()); // 设置用户ID
zhiyuanzheService.insert(zhiyuanzhe); // 插入新用户
return R.ok(); // 返回成功结果
}
/**
*
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody ZhiyuanzheEntity zhiyuanzhe, HttpServletRequest request){
//ValidatorUtils.validateEntity(zhiyuanzhe);
zhiyuanzheService.updateById(zhiyuanzhe);//全部更新
return R.ok();
}
/**
*
* @param zhiyuanzhe
* @param request HTTP
* @return
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody ZhiyuanzheEntity zhiyuanzhe, HttpServletRequest request) {
// ValidatorUtils.validateEntity(zhiyuanzhe); // 验证用户实体(可选)
zhiyuanzheService.updateById(zhiyuanzhe); // 全量更新用户信息
return R.ok(); // 返回成功结果
}
/**
*
* @param ids ID
* @return
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids) {
zhiyuanzheService.deleteBatchIds(Arrays.asList(ids)); // 批量删除用户
return R.ok(); // 返回成功结果
}
/**
*
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
zhiyuanzheService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
*
*/
/**
*
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); // 设置查询字段
map.put("type", type); // 设置查询类型
if ("2".equals(type)) { // 如果类型为2
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; // 初始化结束日期
if (map.get("remindstart") != null) { // 如果有开始日期
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindStart); // 添加天数
remindStartDate = c.getTime(); // 获取新的日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
if (map.get("remindend") != null) { // 如果有结束日期
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.setTime(new Date()); // 设置当前日期
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 添加天数
remindEndDate = c.getTime(); // 获取新的日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
}
}
Wrapper<ZhiyuanzheEntity> wrapper = new EntityWrapper<ZhiyuanzheEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
Wrapper<ZhiyuanzheEntity> wrapper = new EntityWrapper<ZhiyuanzheEntity>(); // 创建查询条件
if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
}
int count = zhiyuanzheService.selectCount(wrapper);
return R.ok().put("count", count);
int count = zhiyuanzheService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); // 返回查询结果
}
}

Loading…
Cancel
Save