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

@ -1,9 +1,26 @@
<template> <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"> <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> </el-breadcrumb-item>
</transition-group> </transition-group>
</el-breadcrumb> </el-breadcrumb>
@ -12,81 +29,99 @@
<script> <script>
import pathToRegexp from 'path-to-regexp' import pathToRegexp from 'path-to-regexp'
import { generateTitle } from '@/utils/i18n' import { generateTitle } from '@/utils/i18n'
export default { export default {
data() { data() {
return { return {
levelList: null levelList: null //
} }
}, },
//
watch: { watch: {
$route() { $route() {
this.getBreadcrumb() this.getBreadcrumb()
} }
}, },
//
created() { created() {
this.getBreadcrumb() this.getBreadcrumb()
this.breadcrumbStyleChange() this.breadcrumbStyleChange()
}, },
methods: { methods: {
// utils/i18n
generateTitle, generateTitle,
//
getBreadcrumb() { getBreadcrumb() {
// only show routes with meta.title
let route = this.$route 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] 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) { isDashboard(route) {
const name = route && route.name const name = route && route.name
if (!name) { if (!name) return false
return false
}
return name.trim().toLocaleLowerCase() === 'Index'.toLocaleLowerCase() return name.trim().toLocaleLowerCase() === 'Index'.toLocaleLowerCase()
}, },
//
pathCompile(path) { pathCompile(path) {
// To solve this problem https://github.com/PanJiaChen/vue-element-admin/issues/561
const { params } = this.$route const { params } = this.$route
var toPath = pathToRegexp.compile(path) const toPath = pathToRegexp.compile(path) //
return toPath(params) return toPath(params) //
}, },
//
handleLink(item) { handleLink(item) {
const { redirect, path } = item const { redirect, path } = item
if (redirect) { if (redirect) {
this.$router.push(redirect) this.$router.push(redirect) //
return return
} }
this.$router.push(path) this.$router.push(path) //
}, },
//
breadcrumbStyleChange(val) { breadcrumbStyleChange(val) {
this.$nextTick(()=>{ this.$nextTick(() => {
document.querySelectorAll('.app-breadcrumb .el-breadcrumb__separator').forEach(el=>{ //
el.innerText = "/" document.querySelectorAll('.app-breadcrumb .el-breadcrumb__separator').forEach(el => {
el.style.color = "rgba(217, 217, 217, 1)" 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" let str = "2"
if(2 == str) { if (2 == str) {
let headHeight = "80px" let headHeight = "80px"
headHeight = parseInt(headHeight) + 10 + 'px' headHeight = parseInt(headHeight) + 10 + 'px' //
document.querySelectorAll('.app-breadcrumb').forEach(el=>{ document.querySelectorAll('.app-breadcrumb').forEach(el => {
el.style.marginTop = headHeight el.style.marginTop = headHeight //
}) })
} }
}) })
}, }
} }
} }
</script>
//
<style lang="scss" scoped> <style lang="scss" scoped>
.app-breadcrumb { .app-breadcrumb {
display: block; display: block;
@ -97,13 +132,12 @@ export default {
display: flex; display: flex;
width: 100%; width: 100%;
height: 100%; height: 100%;
justify-content: flex-start; justify-content: flex-start; /* 默认左对齐 */
align-items: center; align-items: center;
} }
.no-redirect { .no-redirect {
color: #97a8be; color: #97a8be; /* 不可点击项的颜色 */
cursor: text; cursor: text; /* 设置鼠标悬停时为文本光标 */
} }
}
</style> </style>

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

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

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

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

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

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

@ -1,26 +1,65 @@
<template> <template>
<el-aside class="index-aside" width="200px"> <el-aside class="index-aside" width="200px">
<div class="index-aside-inner menulist"> <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"> <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> </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"> <template slot="title">
<i v-if="false" class="el-icon-menu el-icon-user-solid" /> <i v-if="false" class="el-icon-menu el-icon-user-solid" />
<span>个人中心</span> <span>个人中心</span>
</template> </template>
<el-menu-item :index="1-1" @click="menuHandler('updatePassword')"></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-menu-item :index="1 - 2" @click="menuHandler('center')"></el-menu-item>
</el-submenu> </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"> <template slot="title">
<i v-if="false" class="el-icon-menu" :class="icons[index]" /> <i v-if="false" class="el-icon-menu" :class="icons[index]" />
<span>{{ menu.menu }}</span> <span>{{ menu.menu }}</span>
</template> </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-submenu>
</el-menu> </el-menu>
</div> </div>
@ -30,12 +69,13 @@
<script> <script>
import menu from '@/utils/menu' import menu from '@/utils/menu'
export default { export default {
data() { data() {
return { return {
menuList: [], menuList: [], //
dynamicMenuRoutes: [], dynamicMenuRoutes: [], //
role: '', role: '', //
icons: [ icons: [
'el-icon-s-cooperation', 'el-icon-s-cooperation',
'el-icon-s-order', 'el-icon-s-order',
@ -78,12 +118,13 @@ export default {
'el-icon-stopwatch', 'el-icon-stopwatch',
], ],
menulistStyle: '${template.back.menulist.menulistStyle}', menulistStyle: '${template.back.menulist.menulistStyle}',
menulistBorderBottom: {}, menulistBorderBottom: {}, //
} }
}, },
mounted() { mounted() {
//
const menus = menu.list() const menus = menu.list()
if(menus) { if (menus) {
this.menuList = menus this.menuList = menus
} else { } else {
let params = { let params = {
@ -95,24 +136,23 @@ export default {
url: "menu/list", url: "menu/list",
method: "get", method: "get",
params: params params: params
}).then(({ }).then(({ data }) => {
data
}) => {
if (data && data.code === 0) { if (data && data.code === 0) {
this.menuList = JSON.parse(data.data.list[0].menujson); this.menuList = JSON.parse(data.data.list[0].menujson)
this.$storage.set("menus", this.menuList); this.$storage.set("menus", this.menuList)
} }
}) })
} }
//
this.role = this.$storage.get('role') this.role = this.$storage.get('role')
}, },
created(){ created() {
setTimeout(()=>{ //
setTimeout(() => {
this.menulistStyleChange() this.menulistStyleChange()
},10) }, 10)
this.icons.sort(()=>{ //
return (0.5-Math.random()) this.icons.sort(() => 0.5 - Math.random())
})
this.lineBorder() this.lineBorder()
}, },
methods: { methods: {
@ -121,7 +161,8 @@ export default {
let w = '${template.back.menulist.menulistLineWidth}' let w = '${template.back.menulist.menulistLineWidth}'
let s = '${template.back.menulist.menulistLineStyle}' let s = '${template.back.menulist.menulistLineStyle}'
let c = '${template.back.menulist.menulistLineColor}' let c = '${template.back.menulist.menulistLineColor}'
if(style == 'vertical') {
if (style == 'vertical') {
this.menulistBorderBottom = { this.menulistBorderBottom = {
borderBottomWidth: w, borderBottomWidth: w,
borderBottomStyle: s, borderBottomStyle: s,
@ -137,87 +178,84 @@ export default {
}, },
menuHandler(name) { menuHandler(name) {
let router = this.$router let router = this.$router
name = '/'+name name = '/' + name
router.push(name) router.push(name)
}, },
// //
setMenulistHoverColor(){ menulistStyleChange() {
let that = this this.setMenulistIconColor()
return; this.setMenulistHoverColor()
this.$nextTick(()=>{ this.setMenulistStyleHeightChange()
document.querySelectorAll('.menulist .el-menu-item').forEach(el=>{ 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 => { el.addEventListener("mouseenter", e => {
e.stopPropagation() e.stopPropagation()
el.style.backgroundColor = "${template.back.menulist.menulistHoverColor}" el.style.backgroundColor = "${template.back.menulist.menulistHoverColor}"
}) })
el.addEventListener("mouseleave", e => { el.addEventListener("mouseleave", e => {
e.stopPropagation() e.stopPropagation()
// el.style.backgroundColor = "${template.back.menulist.menulistBgColor}" el.style.backgroundColor = "none"
el.style.background = "none"
}) })
el.addEventListener("focus", e => { el.addEventListener("focus", e => {
e.stopPropagation() e.stopPropagation()
el.style.backgroundColor = "${template.back.menulist.menulistHoverColor}" 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 => { el.addEventListener("mouseenter", e => {
e.stopPropagation() e.stopPropagation()
el.style.backgroundColor = "${template.back.menulist.menulistHoverColor}" el.style.backgroundColor = "${template.back.menulist.menulistHoverColor}"
}) })
el.addEventListener("mouseleave", e => { el.addEventListener("mouseleave", e => {
e.stopPropagation() e.stopPropagation()
// el.style.backgroundColor = "${template.back.menulist.menulistBgColor}" el.style.backgroundColor = "none"
el.style.background = "none"
}) })
}) })
}) })
}, },
setMenulistIconColor() { setMenulistIconColor() {
this.$nextTick(()=>{ this.$nextTick(() => {
document.querySelectorAll('.menulist .el-submenu__title .el-submenu__icon-arrow').forEach(el=>{ document.querySelectorAll('.menulist .el-submenu__title .el-submenu__icon-arrow').forEach(el => {
el.style.color = "${template.back.menulist.menulistIconColor}" 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() { setMenulistStyleHeightChange() {
return; return
this.$nextTick(()=>{ this.$nextTick(() => {
document.querySelectorAll('.menulist-item>.el-menu--horizontal>.el-menu-item').forEach(el=>{ document.querySelectorAll('.menulist-item>.el-menu--horizontal>.el-menu-item').forEach(el => {
el.style.height = "${template.back.menulist.menulistHeight}" el.style.height = "${template.back.menulist.menulistHeight}"
el.style.lineHeight = "${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.height = "${template.back.menulist.menulistHeight}"
el.style.lineHeight = "${template.back.menulist.menulistHeight}" el.style.lineHeight = "${template.back.menulist.menulistHeight}"
}) })
@ -226,11 +264,12 @@ export default {
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.el-container { .el-container {
display: block; display: block;
} }
.index-aside { .index-aside {
position: relative; position: relative;
overflow: hidden; overflow: hidden;
display: flex; display: flex;
@ -271,6 +310,7 @@ export default {
.index-aside .index-aside-inner.menulist { .index-aside .index-aside-inner.menulist {
height: auto !important; height: auto !important;
} }
.menulist-item { .menulist-item {
width: 200px; width: 200px;
padding: 15px 20px; padding: 15px 20px;
@ -280,14 +320,15 @@ export default {
border-style: solid !important; border-style: solid !important;
border-color: rgba(254, 236, 190, 1) !important; border-color: rgba(254, 236, 190, 1) !important;
background: #FEECBE !important; background: #FEECBE !important;
box-shadow: 0 0 6px rgba(30, 144, 255, .2); box-shadow: 0 0 6px rgba(30, 144, 255, 0.2);
box-sizing: border-box; box-sizing: border-box;
} }
.el-menu-demo { .el-menu-demo {
box-sizing: border-box; box-sizing: border-box;
min-height: calc(100vh - 80px); min-height: calc(100vh - 80px);
&>.el-menu-item { & > .el-menu-item {
width: auto; width: auto;
height: auto !important; height: auto !important;
line-height: 24px !important; line-height: 24px !important;
@ -300,7 +341,7 @@ export default {
border-style: solid; border-style: solid;
border-color: rgba(79, 150, 68, 1) !important; border-color: rgba(79, 150, 68, 1) !important;
background-color: rgba(98, 190, 84, 1) !important; background-color: rgba(98, 190, 84, 1) !important;
box-shadow: 0 0 6px rgba(255,255,255,0); box-shadow: 0 0 6px rgba(255, 255, 255, 0);
box-sizing: initial; box-sizing: initial;
display: flex; display: flex;
align-items: center; align-items: center;
@ -318,8 +359,8 @@ export default {
border-width: 0; border-width: 0;
border-style: solid; border-style: solid;
border-color: #fff; border-color: #fff;
background-color: rgba(255,255,255,0); background-color: rgba(255, 255, 255, 0);
box-shadow: 0 0 6px rgba(255,255,255,0); box-shadow: 0 0 6px rgba(255, 255, 255, 0);
} }
} }
@ -339,7 +380,7 @@ export default {
border-style: solid; border-style: solid;
border-color: rgba(79, 150, 68, 1) !important; border-color: rgba(79, 150, 68, 1) !important;
background-color: rgba(98, 190, 84, 1) !important; background-color: rgba(98, 190, 84, 1) !important;
box-shadow: 0 0 6px rgba(255,255,255,0); box-shadow: 0 0 6px rgba(255, 255, 255, 0);
box-sizing: initial; box-sizing: initial;
display: flex; display: flex;
align-items: center; align-items: center;
@ -357,8 +398,8 @@ export default {
border-width: 0; border-width: 0;
border-style: solid; border-style: solid;
border-color: #fff; border-color: #fff;
background-color: rgba(255,255,255,0); background-color: rgba(255, 255, 255, 0);
box-shadow: 0 0 6px rgba(255,255,255,0); box-shadow: 0 0 6px rgba(255, 255, 255, 0);
} }
.el-submenu__icon-arrow { .el-submenu__icon-arrow {
@ -372,8 +413,8 @@ export default {
border-width: 0; border-width: 0;
border-style: solid; border-style: solid;
border-color: #fff; border-color: #fff;
background-color: rgba(255,255,255,0); background-color: rgba(255, 255, 255, 0);
box-shadow: 0 0 6px rgba(255,255,255,0); box-shadow: 0 0 6px rgba(255, 255, 255, 0);
position: absolute; position: absolute;
top: 50%; top: 50%;
right: 0; right: 0;
@ -391,9 +432,9 @@ export default {
border-radius: 4px; border-radius: 4px;
border-width: 0; border-width: 0;
border-style: solid; border-style: solid;
border-color: rgba(0,0,0,.3); border-color: rgba(0, 0, 0, 0.3);
background-color: rgba(88, 171, 75, 1); background-color: rgba(88, 171, 75, 1);
box-shadow: 0 0 6px rgba(0, 0, 0, .3); box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
.el-menu-item { .el-menu-item {
width: 100%; width: 100%;
@ -448,10 +489,10 @@ export default {
} }
} }
} }
} }
</style>
<style>
/* 弹出菜单样式 */
<style>
.el-menu--horizontal .el-menu--popup { .el-menu--horizontal .el-menu--popup {
width: 120px; width: 120px;
height: auto; height: auto;
@ -460,11 +501,12 @@ export default {
border-radius: 4px; border-radius: 4px;
border-width: 0; border-width: 0;
border-style: solid; border-style: solid;
border-color: rgba(0,0,0,.3); border-color: rgba(0, 0, 0, 0.3);
background-color: rgba(88, 171, 75, 1); background-color: rgba(88, 171, 75, 1);
box-shadow: 0 0 6px rgba(0, 0, 0, .3); box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
min-width: auto; min-width: auto;
} }
.el-menu--horizontal .el-menu--popup .el-menu-item { .el-menu--horizontal .el-menu--popup .el-menu-item {
width: 100%; width: 100%;
height: 44px; height: 44px;
@ -481,8 +523,9 @@ export default {
box-shadow: 0 0 6px rgba(30, 144, 255, 0); box-shadow: 0 0 6px rgba(30, 144, 255, 0);
text-align: center; text-align: center;
min-width: auto; min-width: auto;
} }
.el-menu--horizontal .el-menu--popup .el-menu-item:hover {
.el-menu--horizontal .el-menu--popup .el-menu-item:hover {
width: 100%; width: 100%;
height: 44px; height: 44px;
line-height: 44px; line-height: 44px;
@ -497,5 +540,5 @@ export default {
background-color: rgba(255, 255, 255, 1) !important; background-color: rgba(255, 255, 255, 1) !important;
box-shadow: 0 0 6px rgba(30, 144, 255, 0); box-shadow: 0 0 6px rgba(30, 144, 255, 0);
text-align: center; text-align: center;
} }
</style> </style>

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

@ -1,25 +1,19 @@
<template> <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="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'}"> <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> <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 class="title-name" :style="{color:heads.headFontColor,fontSize:heads.headFontSize}">{{this.$project.projectName}}</div>
</div> </div>
<!-- 右侧用户信息和退出按钮 -->
<div class="right-menu"> <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 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 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 class="logout" :style="{color:heads.headLogoutFontColor,fontSize:heads.headLogoutFontSize}" @click="onLogout">退</div>
</div> </div>
</div> </div>
@ -32,154 +26,144 @@
dialogVisible: false, dialogVisible: false,
ruleForm: {}, ruleForm: {},
user: {}, 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"}, 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() { created() {
this.setHeaderStyle() //
this.setHeaderStyle();
}, },
mounted() { mounted() {
let sessionTable = this.$storage.get("sessionTable") let sessionTable = this.$storage.get("sessionTable");
//
this.$http({ this.$http({
url: sessionTable + '/session', url: sessionTable + "/session",
method: "get" method: "get"
}).then(({ }).then(({ data }) => {
data
}) => {
if (data && data.code === 0) { if (data && data.code === 0) {
// user
this.user = data.data; this.user = data.data;
this.$storage.set('userid',data.data.id); this.$storage.set("userid", data.data.id);
} else { } else {
let message = this.$message //
let message = this.$message;
message.error(data.msg); message.error(data.msg);
} }
}); });
}, },
methods: { methods: {
// 退
onLogout() { onLogout() {
let storage = this.$storage let storage = this.$storage;
let router = this.$router let router = this.$router;
storage.clear() //
storage.clear();
router.replace({ router.replace({
name: "login" name: "login"
}); });
}, },
onIndexTap(){ // 退
window.location.href = `${this.$base.indexUrl}` onIndexTap() {
//
window.location.href = `${this.$base.indexUrl}`;
}, },
//
setHeaderStyle() { setHeaderStyle() {
this.$nextTick(()=>{ this.$nextTick(() => {
document.querySelectorAll('.navbar .right-menu .logout').forEach(el=>{ document.querySelectorAll('.navbar .right-menu .logout').forEach(el => {
el.addEventListener("mouseenter", e => { el.addEventListener("mouseenter", e => {
e.stopPropagation() e.stopPropagation();
el.style.backgroundColor = this.heads.headLogoutFontHoverBgColor //
el.style.color = this.heads.headLogoutFontHoverColor el.style.backgroundColor = this.heads.headLogoutFontHoverBgColor;
}) el.style.color = this.heads.headLogoutFontHoverColor;
});
el.addEventListener("mouseleave", e => { el.addEventListener("mouseleave", e => {
e.stopPropagation() e.stopPropagation();
el.style.backgroundColor = "transparent" //
el.style.color = this.heads.headLogoutFontColor el.style.backgroundColor = "transparent";
}) el.style.color = this.heads.headLogoutFontColor;
}) });
}) });
});
}, },
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.navbar { .navbar {
height: 60px; height: 60px; /* 设置导航栏高度 */
line-height: 60px; line-height: 60px; /* 设置文本垂直居中 */
width: 100%; width: 100%; /* 设置宽度为100% */
padding: 0 34px; padding: 0 34px; /* 设置左右内边距 */
box-sizing: border-box; box-sizing: border-box; /* 确保padding不会增加总宽度 */
background-color: #ff00ff; background-color: #ff00ff; /* 设置背景颜色 */
position: relative; position: relative; /* 相对定位 */
z-index: 111; z-index: 111; /* 设置堆叠顺序 */
.right-menu { .right-menu {
position: absolute; position: absolute; /* 绝对定位 */
right: 34px; right: 34px; /* 右侧距离 */
top: 0; top: 0; /* 顶部对齐 */
height: 100%; height: 100%; /* 占据整个高度 */
display: flex; display: flex; /* 弹性布局 */
justify-content: flex-end; justify-content: flex-end; /* 内容右对齐 */
align-items: center; align-items: center; /* 垂直居中 */
z-index: 111; z-index: 111; /* 设置堆叠顺序 */
.user-info { .user-info {
font-size: 16px; font-size: 16px; /* 字体大小 */
color: red; color: red; /* 文字颜色 */
padding: 0 12px; padding: 0 12px; /* 内边距 */
} }
.logout { .logout {
font-size: 16px; font-size: 16px; /* 字体大小 */
color: red; color: red; /* 文字颜色 */
padding: 0 12px; padding: 0 12px; /* 内边距 */
cursor: pointer; cursor: pointer; /* 鼠标悬停时显示手型 */
} }
} }
.title-menu { .title-menu {
display: flex; display: flex; /* 弹性布局 */
justify-content: flex-start; justify-content: flex-start; /* 内容左对齐 */
align-items: center; align-items: center; /* 垂直居中 */
width: 100%; width: 100%; /* 占据整个宽度 */
height: 100%; height: 100%; /* 占据整个高度 */
.title-img { .title-img {
width: 44px; width: 44px; /* 图片宽度 */
height: 44px; height: 44px; /* 图片高度 */
border-radius: 22px; border-radius: 22px; /* 圆角 */
box-shadow: 0 1px 6px #444; box-shadow: 0 1px 6px #444; /* 添加阴影 */
margin-right: 16px; margin-right: 16px; /* 图片右侧间距 */
} }
.title-name { .title-name {
font-size: 24px; font-size: 24px; /* 字体大小 */
color: #fff; color: #fff; /* 文字颜色 */
font-weight: 700; font-weight: 700; /* 加粗 */
} }
} }
} }
// .el-header .fr {
// float: right;
// }
// .el-header .fl {
// float: left;
// }
// .el-header {
// width: 100%;
// color: #333;
// text-align: center;
// line-height: 60px;
// padding: 0;
// z-index: 99;
// }
// .logo {
// width: 60px;
// height: 60px;
// margin-left: 70px;
// }
// .avator {
// width: 40px;
// height: 40px;
// background: #ffffff;
// border-radius: 50%;
// }
// .title {
// color: #ffffff;
// font-size: 20px;
// font-weight: bold;
// margin-left: 20px;
// }
</style> </style>

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

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

@ -9,6 +9,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupp
import com.interceptor.AuthorizationInterceptor; import com.interceptor.AuthorizationInterceptor;
@Configuration @Configuration
<<<<<<< HEAD
public class InterceptorConfig extends WebMvcConfigurationSupport{ public class InterceptorConfig extends WebMvcConfigurationSupport{
@Bean @Bean
@ -26,13 +27,40 @@ public class InterceptorConfig extends WebMvcConfigurationSupport{
* springboot 2.0WebMvcConfigurationSupport访addResourceHandlers * springboot 2.0WebMvcConfigurationSupport访addResourceHandlers
*/ */
@Override @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) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
// 添加资源处理器,处理所有路径的静态资源请求
registry.addResourceHandler("/**") registry.addResourceHandler("/**")
.addResourceLocations("classpath:/resources/") .addResourceLocations("classpath:/resources/") // 从 classpath:/resources/ 目录加载资源
.addResourceLocations("classpath:/static/") .addResourceLocations("classpath:/static/") // 从 classpath:/static/ 目录加载资源
.addResourceLocations("classpath:/admin/") .addResourceLocations("classpath:/admin/") // 从 classpath:/admin/ 目录加载资源
.addResourceLocations("classpath:/front/") .addResourceLocations("classpath:/front/") // 从 classpath:/front/ 目录加载资源
.addResourceLocations("classpath:/public/"); .addResourceLocations("classpath:/public/"); // 从 classpath:/public/ 目录加载资源
super.addResourceHandlers(registry); super.addResourceHandlers(registry); // 调用父类方法继续处理其他资源处理器
} }
} }

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

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

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

@ -19,11 +19,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils; import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.*;
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.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.annotation.IgnoreAuth; import com.annotation.IgnoreAuth;
@ -34,83 +30,95 @@ import com.service.ConfigService;
import com.utils.R; import com.utils.R;
/** /**
* *
*/ */
@RestController @RestController
@RequestMapping("file") @RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"}) @SuppressWarnings({"unchecked","rawtypes"})
public class FileController{ public class FileController {
@Autowired @Autowired
private ConfigService configService; private ConfigService configService; // 注入配置服务类
/** /**
* *
* @param file
* @param type 1
* @return
* @throws Exception
*/ */
@RequestMapping("/upload") @RequestMapping("/upload")
public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception { public R upload(@RequestParam("file") MultipartFile file, String type) throws Exception {
if (file.isEmpty()) { if (file.isEmpty()) { // 检查文件是否为空
throw new EIException("上传文件不能为空"); throw new EIException("上传文件不能为空"); // 抛出异常
} }
String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
File path = new File(ResourceUtils.getURL("classpath:static").getPath()); String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); // 获取文件扩展名
if(!path.exists()) { File path = new File(ResourceUtils.getURL("classpath:static").getPath()); // 获取静态资源路径
path = new File(""); if (!path.exists()) { // 如果路径不存在
path = new File(""); // 设置默认路径
} }
File upload = new File(path.getAbsolutePath(),"/upload/");
if(!upload.exists()) { File upload = new File(path.getAbsolutePath(), "/upload/"); // 定义上传目录
upload.mkdirs(); if (!upload.exists()) { // 如果上传目录不存在
upload.mkdirs(); // 创建目录
} }
String fileName = new Date().getTime()+"."+fileExt;
File dest = new File(upload.getAbsolutePath()+"/"+fileName); String fileName = new Date().getTime() + "." + fileExt; // 生成唯一的文件名
file.transferTo(dest); File dest = new File(upload.getAbsolutePath() + "/" + fileName); // 定义目标文件路径
file.transferTo(dest); // 将文件保存到目标位置
/** /**
* 使ideaeclipse * 使IDEIntelliJ IDEAEclipse
* "D:\\springbootq33sd\\src\\main\\resources\\static\\upload"upload * 1.
* * 2. "D:\\\\springbootq33sd\\\\src\\\\main\\\\resources\\\\static\\\\upload"
* 3.
*/ */
// FileUtils.copyFile(dest, new File("D:\\springbootq33sd\\src\\main\\resources\\static\\upload"+"/"+fileName)); /**修改了路径以后请将该行最前面的//注释去掉**/ // 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 (StringUtils.isNotBlank(type) && type.equals("1")) { // 如果类型为1人脸文件
if(configEntity==null) { ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile")); // 查询配置项
configEntity = new ConfigEntity(); if (configEntity == null) { // 如果配置项不存在
configEntity.setName("faceFile"); configEntity = new ConfigEntity(); // 创建新配置项
configEntity.setValue(fileName); configEntity.setName("faceFile"); // 设置配置项名称
configEntity.setValue(fileName); // 设置文件名
} else { } 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 @IgnoreAuth
@RequestMapping("/download") @RequestMapping("/download")
public ResponseEntity<byte[]> download(@RequestParam String fileName) { public ResponseEntity<byte[]> download(@RequestParam String fileName) {
try { try {
File path = new File(ResourceUtils.getURL("classpath:static").getPath()); File path = new File(ResourceUtils.getURL("classpath:static").getPath()); // 获取静态资源路径
if(!path.exists()) { if (!path.exists()) { // 如果路径不存在
path = new File(""); path = new File(""); // 设置默认路径
} }
File upload = new File(path.getAbsolutePath(),"/upload/");
if(!upload.exists()) { File upload = new File(path.getAbsolutePath(), "/upload/"); // 定义上传目录
upload.mkdirs(); if (!upload.exists()) { // 如果上传目录不存在
upload.mkdirs(); // 创建目录
} }
File file = new File(upload.getAbsolutePath()+"/"+fileName);
if(file.exists()){ File file = new File(upload.getAbsolutePath() + "/" + fileName); // 定义目标文件路径
/*if(!fileService.canRead(file, SessionManager.getSessionUser())){ if (file.exists()) { // 如果文件存在
getResponse().sendError(403); HttpHeaders headers = new HttpHeaders(); // 设置响应头
}*/ headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); // 设置内容类型
HttpHeaders headers = new HttpHeaders(); headers.setContentDispositionFormData("attachment", fileName); // 设置附件下载
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file), headers, HttpStatus.OK); // 返回文件流
headers.setContentDispositionFormData("attachment", fileName);
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
} }
} catch (IOException e) { } 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; import java.io.IOException;
/** /**
* *
* * @author []
* @author * @email []
* @email
* @date 2022-05-06 08:33:49 * @date 2022-05-06 08:33:49
*/ */
@RestController @RestController
@RequestMapping("/huodongbaoming") @RequestMapping("/huodongbaoming")
public class HuodongbaomingController { public class HuodongbaomingController {
@Autowired @Autowired
private HuodongbaomingService huodongbaomingService; private HuodongbaomingService huodongbaomingService; // 注入活动报名服务
/** /**
* *
* @param params
* @param huodongbaoming
* @param request HTTP
* @return
*/ */
@RequestMapping("/page") @RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,HuodongbaomingEntity huodongbaoming, public R page(@RequestParam Map<String, Object> params, HuodongbaomingEntity huodongbaoming,
HttpServletRequest request){ HttpServletRequest request) {
String tableName = request.getSession().getAttribute("tableName").toString(); String tableName = request.getSession().getAttribute("tableName").toString(); // 获取当前用户表名
if(tableName.equals("zhiyuanzhe")) { if (tableName.equals("zhiyuanzhe")) { // 如果是志愿者表
huodongbaoming.setXuehao((String)request.getSession().getAttribute("username")); huodongbaoming.setXuehao((String) request.getSession().getAttribute("username")); // 设置学号
} }
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<HuodongbaomingEntity>();
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongbaomingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongbaoming), params), params)); PageUtils page = huodongbaomingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongbaoming), params), params));
return R.ok().put("data", page); return R.ok().put("data", page); // 返回分页数据
} }
/** /**
* *
* @param params
* @param huodongbaoming
* @param request HTTP
* @return
*/ */
@IgnoreAuth @IgnoreAuth
@RequestMapping("/list") @RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,HuodongbaomingEntity huodongbaoming, public R list(@RequestParam Map<String, Object> params, HuodongbaomingEntity huodongbaoming,
HttpServletRequest request){ HttpServletRequest request) {
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<HuodongbaomingEntity>(); EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<>(); // 创建查询条件
PageUtils page = huodongbaomingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongbaoming), params), params)); PageUtils page = huodongbaomingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huodongbaoming), params), params));
return R.ok().put("data", page);
return R.ok().put("data", page); // 返回分页数据
} }
/** /**
* *
* @param huodongbaoming
* @return
*/ */
@RequestMapping("/lists") @RequestMapping("/lists")
public R list( HuodongbaomingEntity huodongbaoming){ public R list(HuodongbaomingEntity huodongbaoming) {
EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<HuodongbaomingEntity>(); EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre( huodongbaoming, "huodongbaoming")); ew.allEq(MPUtil.allEQMapPre(huodongbaoming, "huodongbaoming")); // 设置查询条件
return R.ok().put("data", huodongbaomingService.selectListView(ew)); return R.ok().put("data", huodongbaomingService.selectListView(ew)); // 返回数据列表
} }
/** /**
* *
* @param huodongbaoming
* @return
*/ */
@RequestMapping("/query") @RequestMapping("/query")
public R query(HuodongbaomingEntity huodongbaoming){ public R query(HuodongbaomingEntity huodongbaoming) {
EntityWrapper< HuodongbaomingEntity> ew = new EntityWrapper< HuodongbaomingEntity>(); EntityWrapper<HuodongbaomingEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre( huodongbaoming, "huodongbaoming")); ew.allEq(MPUtil.allEQMapPre(huodongbaoming, "huodongbaoming")); // 设置查询条件
HuodongbaomingView huodongbaomingView = huodongbaomingService.selectView(ew); HuodongbaomingView huodongbaomingView = huodongbaomingService.selectView(ew); // 查询视图
return R.ok("查询活动报名成功").put("data", huodongbaomingView); return R.ok("查询活动报名成功").put("data", huodongbaomingView); // 返回查询结果
} }
/** /**
* *
* @param id ID
* @return
*/ */
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){ public R info(@PathVariable("id") Long id) {
HuodongbaomingEntity huodongbaoming = huodongbaomingService.selectById(id); HuodongbaomingEntity huodongbaoming = huodongbaomingService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongbaoming); return R.ok().put("data", huodongbaoming); // 返回记录详情
} }
/** /**
* *
* @param id ID
* @return
*/ */
@IgnoreAuth @IgnoreAuth
@RequestMapping("/detail/{id}") @RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){ public R detail(@PathVariable("id") Long id) {
HuodongbaomingEntity huodongbaoming = huodongbaomingService.selectById(id); HuodongbaomingEntity huodongbaoming = huodongbaomingService.selectById(id); // 查询单条记录
return R.ok().put("data", huodongbaoming); return R.ok().put("data", huodongbaoming); // 返回记录详情
} }
/** /**
* *
* @param huodongbaoming
* @param request HTTP
* @return
*/ */
@RequestMapping("/save") @RequestMapping("/save")
public R save(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request){ public R save(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request) {
huodongbaoming.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); huodongbaoming.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
//ValidatorUtils.validateEntity(huodongbaoming); huodongbaomingService.insert(huodongbaoming); // 插入数据
huodongbaomingService.insert(huodongbaoming); return R.ok(); // 返回成功结果
return R.ok();
} }
/** /**
* *
* @param huodongbaoming
* @param request HTTP
* @return
*/ */
@RequestMapping("/add") @RequestMapping("/add")
public R add(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request){ public R add(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request) {
huodongbaoming.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); huodongbaoming.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue()); // 生成唯一ID
//ValidatorUtils.validateEntity(huodongbaoming); huodongbaomingService.insert(huodongbaoming); // 插入数据
huodongbaomingService.insert(huodongbaoming); return R.ok(); // 返回成功结果
return R.ok();
} }
/** /**
* *
* @param huodongbaoming
* @param request HTTP
* @return
*/ */
@RequestMapping("/update") @RequestMapping("/update")
@Transactional @Transactional
public R update(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request){ public R update(@RequestBody HuodongbaomingEntity huodongbaoming, HttpServletRequest request) {
//ValidatorUtils.validateEntity(huodongbaoming); huodongbaomingService.updateById(huodongbaoming); // 全量更新
huodongbaomingService.updateById(huodongbaoming);//全部更新 return R.ok(); // 返回成功结果
return R.ok();
} }
/** /**
* *
* @param ids ID
* @return
*/ */
@RequestMapping("/delete") @RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){ public R delete(@RequestBody Long[] ids) {
huodongbaomingService.deleteBatchIds(Arrays.asList(ids)); huodongbaomingService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
return R.ok(); return R.ok(); // 返回成功结果
} }
/** /**
* *
* @param columnName
* @param request HTTP
* @param type
* @param map
* @return
*/ */
@RequestMapping("/remind/{columnName}/{type}") @RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) { @PathVariable("type") String type, @RequestParam Map<String, Object> map) {
map.put("column", columnName); map.put("column", columnName); // 添加字段名到参数
map.put("type", type); map.put("type", type); // 添加提醒类型到参数
if(type.equals("2")) { if (type.equals("2")) { // 如果是相对日期提醒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance(); // 获取当前日期
Date remindStartDate = null; Date remindStartDate = null; // 初始化开始日期
Date remindEndDate = null; Date remindEndDate = null; // 初始化结束日期
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); if (map.get("remindstart") != null) { // 如果有提醒开始时间
c.setTime(new Date()); Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 转换为整数
c.add(Calendar.DAY_OF_MONTH,remindStart); c.setTime(new Date()); // 设置当前日期
remindStartDate = c.getTime(); c.add(Calendar.DAY_OF_MONTH, remindStart); // 计算开始日期
map.put("remindstart", sdf.format(remindStartDate)); remindStartDate = c.getTime(); // 获取开始日期
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并设置开始日期
} }
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); if (map.get("remindend") != null) { // 如果有提醒结束时间
c.setTime(new Date()); Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 转换为整数
c.add(Calendar.DAY_OF_MONTH,remindEnd); c.setTime(new Date()); // 设置当前日期
remindEndDate = c.getTime(); c.add(Calendar.DAY_OF_MONTH, remindEnd); // 计算结束日期
map.put("remindend", sdf.format(remindEndDate)); remindEndDate = c.getTime(); // 获取结束日期
map.put("remindend", sdf.format(remindEndDate)); // 格式化并设置结束日期
} }
} }
Wrapper<HuodongbaomingEntity> wrapper = new EntityWrapper<HuodongbaomingEntity>(); Wrapper<HuodongbaomingEntity> wrapper = new EntityWrapper<>(); // 创建查询条件
if(map.get("remindstart")!=null) { if (map.get("remindstart") != null) { // 如果有开始日期
wrapper.ge(columnName, map.get("remindstart")); wrapper.ge(columnName, map.get("remindstart")); // 设置大于等于条件
} }
if(map.get("remindend")!=null) { if (map.get("remindend") != null) { // 如果有结束日期
wrapper.le(columnName, map.get("remindend")); wrapper.le(columnName, map.get("remindend")); // 设置小于等于条件
} }
String tableName = request.getSession().getAttribute("tableName").toString(); String tableName = request.getSession().getAttribute("tableName").toString(); // 获取当前用户表名
if(tableName.equals("zhiyuanzhe")) { if (tableName.equals("zhiyuanzhe")) { // 如果是志愿者表
wrapper.eq("xuehao", (String)request.getSession().getAttribute("username")); wrapper.eq("xuehao", (String) request.getSession().getAttribute("username")); // 设置学号条件
} }
int count = huodongbaomingService.selectCount(wrapper); int count = huodongbaomingService.selectCount(wrapper); // 查询符合条件的记录数
return R.ok().put("count", count); return R.ok().put("count", count); // 返回提醒结果
} }
} }

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

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

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

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

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

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

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

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

Loading…
Cancel
Save