2020-09-09
This commit is contained in:
parent
13e68a97c8
commit
4f579d068b
@ -1,9 +1,22 @@
|
||||
package com.qinxx.hslink.controller;
|
||||
|
||||
import com.qinxx.hslink.service.HSService;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.Part;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -14,14 +27,19 @@ import java.util.Map;
|
||||
@RequestMapping("/hs")
|
||||
public class HSController {
|
||||
|
||||
@Autowired
|
||||
/**
|
||||
* 日志
|
||||
*/
|
||||
private static Logger logger = LogManager.getLogger(HSController.class);
|
||||
|
||||
@Resource
|
||||
HSService hsService;
|
||||
|
||||
/**登录验证*/
|
||||
@RequestMapping(value = "/login", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
@ResponseBody
|
||||
public Map<String,Object> hello(@RequestBody Map<String,Object> param) {
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
Map<String,Object> result = new HashMap<>(32);
|
||||
result = hsService.login(param);
|
||||
return result;
|
||||
}
|
||||
@ -30,7 +48,7 @@ public class HSController {
|
||||
@RequestMapping(value = "/register", method = {RequestMethod.POST,RequestMethod.GET})
|
||||
@ResponseBody
|
||||
public Map<String,Object> register(@RequestBody Map<String,Object> param) {
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
Map<String,Object> result = new HashMap<>(32);
|
||||
result = hsService.register(param);
|
||||
return result;
|
||||
}
|
||||
@ -186,4 +204,62 @@ public class HSController {
|
||||
Map<String,Object> result = hsService.timingTask(param);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用 httpServletRequest作为参数
|
||||
* @param httpServletRequest
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
@ResponseBody
|
||||
public Map<String, Object> upload(HttpServletRequest httpServletRequest){
|
||||
return hsService.upload(httpServletRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件列表
|
||||
*/
|
||||
@PostMapping("/getFileList")
|
||||
@ResponseBody
|
||||
public Map<String, Object> getFileList(String[] fileList){
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result = hsService.getFileList(fileList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件下载
|
||||
*/
|
||||
@RequestMapping("/fileDownload")
|
||||
public void fileDownload(HttpServletRequest request, HttpServletResponse response) {
|
||||
hsService.fileDownload(request.getParameter("fileId"),request,response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询轮播图列表
|
||||
*/
|
||||
@PostMapping("/getRotationPhotoList")
|
||||
@ResponseBody
|
||||
public Map<String, Object> getRotationPhotoList(){
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result = hsService.getRotationPhotoList();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取管理员文章审核列表
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 测试接口
|
||||
*/
|
||||
@PostMapping("/test")
|
||||
@ResponseBody
|
||||
public Map<String, Object> test(String page, String limit){
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -154,4 +154,19 @@ public interface HSLinkMapper {
|
||||
*/
|
||||
int updateIntegral(Map<String,Object> param);
|
||||
|
||||
/**
|
||||
* 保存文件路径
|
||||
*/
|
||||
int insertFilePath(Map<String,Object> param);
|
||||
|
||||
/**
|
||||
* 获取文件信息
|
||||
*/
|
||||
List<Map<String,Object>> getFileList();
|
||||
|
||||
/**
|
||||
* 查询轮播图列表
|
||||
* @return
|
||||
*/
|
||||
List<Map<String,Object>> getRotationPhotoList();
|
||||
}
|
||||
|
@ -306,5 +306,43 @@
|
||||
ORDER BY letter_create_time desc
|
||||
</select>
|
||||
|
||||
<!--保存文件路径-->
|
||||
<insert id="insertFilePath" parameterType="map">
|
||||
insert into hs_file_info
|
||||
(id,file_name,file_encryption,file_path,create_time)
|
||||
values
|
||||
(#{id},#{fileName},#{fileEncryption},#{filePath},now())
|
||||
</insert>
|
||||
|
||||
<!--获取文件信息-->
|
||||
<select id="getFileList" resultType="java.util.Map">
|
||||
select
|
||||
id,
|
||||
file_name fileName,
|
||||
file_encryption fileEncryption,
|
||||
file_path filePath,
|
||||
create_time createTime
|
||||
from
|
||||
hs_file_info
|
||||
order by
|
||||
create_time desc
|
||||
</select>
|
||||
|
||||
<!--查询轮播图列表-->
|
||||
<select id="getRotationPhotoList" resultType="java.util.Map">
|
||||
SELECT
|
||||
t.id,
|
||||
file_id fileId,
|
||||
file_name fileName,
|
||||
file_encryption fileEncryption,
|
||||
file_path filePath,
|
||||
type_code typeCode,
|
||||
type_name typeName,
|
||||
i.create_time createTime
|
||||
FROM hs_file_type t
|
||||
left join hs_file_info i on t.file_id = i.id
|
||||
where type_code = 'rotationChart'
|
||||
ORDER BY i.create_time
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -2,6 +2,8 @@ package com.qinxx.hslink.service;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -115,4 +117,25 @@ public interface HSService {
|
||||
* 定时任务
|
||||
*/
|
||||
Map<String,Object> timingTask(Map<String,Object> param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
Map<String, Object> upload(HttpServletRequest httpServletRequest);
|
||||
|
||||
/**
|
||||
* 获取文件列表
|
||||
*/
|
||||
Map<String, Object> getFileList(String[] fileList);
|
||||
|
||||
/**
|
||||
* 文件下载
|
||||
*/
|
||||
void fileDownload(String fileId,HttpServletRequest request, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 查询轮播图列表
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getRotationPhotoList();
|
||||
}
|
@ -1,20 +1,36 @@
|
||||
package com.qinxx.hslink.service.impl;
|
||||
|
||||
import com.qinxx.hslink.controller.HSController;
|
||||
import com.qinxx.hslink.dao.HSLinkMapper;
|
||||
import com.qinxx.hslink.service.HSService;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class HSServiceImpl implements HSService {
|
||||
|
||||
@Autowired
|
||||
/**
|
||||
* 日志
|
||||
*/
|
||||
private static Logger logger = LogManager.getLogger(HSServiceImpl.class);
|
||||
@Resource
|
||||
HSLinkMapper hsLinkMapper;
|
||||
/**文件路径*/
|
||||
@Value("${filePath}")
|
||||
private String filePath;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> login(Map<String, Object> param) {
|
||||
@ -332,4 +348,133 @@ public class HSServiceImpl implements HSService {
|
||||
result.put("success",true);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> upload(HttpServletRequest httpServletRequest) {
|
||||
boolean flag = false;
|
||||
MultipartHttpServletRequest multipartHttpServletRequest = null;
|
||||
//强制转换为MultipartHttpServletRequest接口对象 (它包含所有HttpServletRequest的方法)
|
||||
if(httpServletRequest instanceof MultipartHttpServletRequest){
|
||||
multipartHttpServletRequest = (MultipartHttpServletRequest) httpServletRequest;
|
||||
}else{
|
||||
return dealResultMap(false, "上传失败");
|
||||
}
|
||||
//获取MultipartFile文件信息(注意参数为前端对应的参数名称)
|
||||
MultipartFile mf = multipartHttpServletRequest.getFile("file");
|
||||
//获取源文件名称
|
||||
String fileName = mf.getOriginalFilename();
|
||||
//存储路径可在配置文件中指定
|
||||
File pfile = new File(filePath);
|
||||
if (!pfile.exists()) {
|
||||
pfile.mkdirs();
|
||||
}
|
||||
String id = UUID.randomUUID().toString();
|
||||
File file = new File(pfile,id+fileName);
|
||||
/* //指定好存储路径
|
||||
File file = new File(fileName);*/
|
||||
try {
|
||||
//保存文件
|
||||
//使用此方法保存必须要绝对路径且文件夹必须已存在,否则报错
|
||||
mf.transferTo(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return dealResultMap(false, "上传失败");
|
||||
}
|
||||
//保存文件路径
|
||||
Map<String,Object> param = new HashMap<>();
|
||||
param.put("id", id);
|
||||
param.put("fileName",fileName);
|
||||
param.put("fileEncryption",id+fileName);
|
||||
param.put("filePath",String.valueOf(file));
|
||||
hsLinkMapper.insertFilePath(param);
|
||||
return dealResultMap(true, "上传成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getFileList(String[] fileList) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Map<String, Object> res = new HashMap<>();
|
||||
res.put("fileList",hsLinkMapper.getFileList());
|
||||
result.put("data",res);
|
||||
result.put("success",true);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileDownload(String fileId,HttpServletRequest request, HttpServletResponse response) {
|
||||
// 下载的文件名
|
||||
Map<String, String> fileMap = new HashMap<>();
|
||||
fileMap.put("NAME","test.png");
|
||||
fileMap.put("ID","");
|
||||
String fileName = fileMap.get("NAME");
|
||||
String id = fileMap.get("ID");
|
||||
String prefix = fileName.substring(fileName.lastIndexOf("."));
|
||||
// 文件路径
|
||||
String path = "D:\\office\\phy\\HSLink\\HSLink-back\\src\\main\\static\\files\\test.png";
|
||||
InputStream bis = null;
|
||||
BufferedOutputStream out = null;
|
||||
// 获取输入流
|
||||
try {
|
||||
bis = new BufferedInputStream(new FileInputStream(new File(path)), 1024 * 10);
|
||||
// 假如以中文名下载的话
|
||||
// 转码,免得文件名中文乱码
|
||||
fileName = URLEncoder.encode(fileName, "UTF-8");
|
||||
// 设置文件下载头
|
||||
response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
|
||||
// 设置文件ContentType类型,这样设置,会自动判断下载文件类型
|
||||
response.setContentType("multipart/form-data");
|
||||
out = new BufferedOutputStream(response.getOutputStream());
|
||||
int len = 0;
|
||||
int i = bis.available();
|
||||
byte[] buff = new byte[i];
|
||||
while ((len = bis.read(buff)) > 0) {
|
||||
out.write(buff, 0, len);
|
||||
out.flush();
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
logger.error("文件未找到" + e.getMessage());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.error("不支持的编码异常:" + e.getMessage());
|
||||
} catch (IOException e) {
|
||||
logger.error("IO异常:" + e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
if (null != bis) {
|
||||
bis.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.error("流关闭异常" + e.getMessage());
|
||||
}
|
||||
try {
|
||||
if (null != out) {
|
||||
out.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.error("流关闭异常" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getRotationPhotoList() {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Map<String, Object> res = new HashMap<>();
|
||||
res.put("rotationPhotoList",hsLinkMapper.getRotationPhotoList());
|
||||
result.put("data",res);
|
||||
result.put("success",true);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回参数
|
||||
* @param flag
|
||||
* @param message
|
||||
* @return
|
||||
*/
|
||||
private Map<String, Object> dealResultMap(boolean flag, String message) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("flag",flag);
|
||||
map.put("message",message);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,14 @@ import java.util.Date;
|
||||
* @author 帅气的布里茨
|
||||
*/
|
||||
public class TestClass {
|
||||
|
||||
/**
|
||||
* 主线程
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
//设置日期格式
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// new Date()为获取当前系统时间
|
||||
System.out.println(df.format(new Date()));
|
||||
final int num = 10;
|
||||
for (int i = 0; i < num; i++) {
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"properties": [
|
||||
{
|
||||
"name": "filePath",
|
||||
"type": "java.lang.String",
|
||||
"description": "Description for filePath."
|
||||
}
|
||||
] }
|
@ -19,3 +19,6 @@ spring:
|
||||
db-name: hslink
|
||||
filters: log4j,wall,mergeStat
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
|
||||
##文件保存路径
|
||||
filePath: D:\office\phy\HSLink\HSLink-front\src\assets\file
|
1
HSLink-back/src/main/static/files/test.png
Normal file
1
HSLink-back/src/main/static/files/test.png
Normal file
@ -0,0 +1 @@
|
||||
测试文件
|
@ -14,6 +14,7 @@
|
||||
"element-ui": "^2.13.0",
|
||||
"jquery": "^3.4.1",
|
||||
"marked": "^0.8.2",
|
||||
"react": "^16.13.1",
|
||||
"vue": "^2.5.2",
|
||||
"vue-router": "^3.0.1",
|
||||
"vue-scroll": "^2.1.13"
|
||||
|
@ -2,8 +2,8 @@
|
||||
import de from "element-ui/src/locale/lang/de";
|
||||
|
||||
// let root = 'http://192.168.10.29:8048'
|
||||
let root = 'http://123.57.22.91:8048'
|
||||
// let root = 'http://127.0.0.1:8048'
|
||||
// let root = 'http://123.57.22.91:8048'
|
||||
let root = 'http://127.0.0.1:8048'
|
||||
// 引用axios
|
||||
let axios = require('axios')
|
||||
// 自定义判断元素类型JS
|
||||
|
@ -11,17 +11,8 @@
|
||||
校<br>园<br>动<br>态
|
||||
</div>
|
||||
<el-carousel indicator-position="outside">
|
||||
<el-carousel-item>
|
||||
<img src="../assets/img/carousel/carousel1.jpg" height="100%" width="100%"/>
|
||||
</el-carousel-item>
|
||||
<el-carousel-item>
|
||||
<img src="../assets/img/carousel/carousel2.jpg" height="100%" width="100%"/>
|
||||
</el-carousel-item>
|
||||
<el-carousel-item>
|
||||
<img src="../assets/img/carousel/carousel3.jpg" height="100%" width="100%"/>
|
||||
</el-carousel-item>
|
||||
<el-carousel-item>
|
||||
<img src="../assets/img/carousel/carousel4.jpg" height="100%" width="100%"/>
|
||||
<el-carousel-item v-for="(item,index) in rotationPhotoList" :key="index">
|
||||
<img :src="item.fileName" height="100%" width="100%"/>
|
||||
</el-carousel-item>
|
||||
</el-carousel>
|
||||
</div>
|
||||
@ -113,6 +104,8 @@
|
||||
name: "Hompage",
|
||||
data() {
|
||||
return{
|
||||
//轮播图片
|
||||
rotationPhotoList: [],
|
||||
tabLoading: false,
|
||||
condition: '',
|
||||
newestNotice: '',
|
||||
@ -176,17 +169,38 @@
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getRotationPhotoList();
|
||||
this.getNoticeList();
|
||||
},
|
||||
methods: {
|
||||
//获取通知列表
|
||||
getNoticeList() {
|
||||
this.tabLoading = true;
|
||||
this.$ajax.post("/hs/getAllContent",{},r=>{
|
||||
this.tabLoading = false;
|
||||
this.newestNotice = r.schoolNoticeList.slice(0,12);
|
||||
this.goodAdvice = r.parentAdvice.slice(0,12);
|
||||
this.magicalThinking = r.studentThinking.slice(0,12);
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
})
|
||||
},
|
||||
//获取轮播图片
|
||||
getRotationPhotoList() {
|
||||
this.$ajax.post('/hs/getRotationPhotoList',{},res=>{
|
||||
console.log("轮播图列表",res);
|
||||
this.rotationPhotoList = [];
|
||||
for (let i = 0; i < res.rotationPhotoList.length; i++) {
|
||||
this.rotationPhotoList.push(
|
||||
{
|
||||
id: res.rotationPhotoList[i].id,
|
||||
fileId: res.rotationPhotoList[i].fileId,
|
||||
fileName: require('../assets/img/carousel/'+res.rotationPhotoList[i].fileName)},
|
||||
);
|
||||
}
|
||||
console.log("rotationPhotoList",this.rotationPhotoList)
|
||||
})
|
||||
},
|
||||
searchLabel(label) {
|
||||
sessionStorage.setItem("condition",label)
|
||||
sessionStorage.setItem("condition",label);
|
||||
this.$router.push({name: "search"})
|
||||
},
|
||||
search() {
|
||||
|
@ -8,13 +8,15 @@ import router from './router'
|
||||
import '@/assets/css/public.css'
|
||||
// 引用API文件
|
||||
import api from './api/index.js'
|
||||
import axios from 'axios'
|
||||
Vue.prototype.$axios = axios;
|
||||
// 将API方法绑定到全局
|
||||
import marked from 'marked'
|
||||
import scroll from 'vue-scroll'
|
||||
Vue.prototype.$ajax = api
|
||||
Vue.config.productionTip = false
|
||||
Vue.prototype.$ajax = api;
|
||||
Vue.config.productionTip = false;
|
||||
Vue.use(ElementUI);
|
||||
Vue.use(scroll)
|
||||
Vue.use(scroll);
|
||||
/* eslint-disable no-new */
|
||||
new Vue({
|
||||
el: '#app',
|
||||
|
@ -9,7 +9,34 @@ export default new Router({
|
||||
path: '/',
|
||||
name: 'login',
|
||||
component:() => import('@/components/Login')
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/upload',
|
||||
name: 'upload',
|
||||
component:() => import('@/view/upload')
|
||||
},
|
||||
{
|
||||
path: '/admin',
|
||||
name: 'admin',
|
||||
component:() => import('@/view/admin/Admin'),
|
||||
children: [
|
||||
{
|
||||
path: '/articlereview',
|
||||
name: 'articlereview',
|
||||
component:() => import('@/view/admin/articleReview/ArticleReview')
|
||||
},
|
||||
{
|
||||
path: '/personnelmanagement',
|
||||
name: 'personnelmanagement',
|
||||
component:() => import('@/view/admin/personnelManagement/PersonnelManagement')
|
||||
},
|
||||
{
|
||||
path: '/homepagemanagement',
|
||||
name: 'homepagemanagement',
|
||||
component:() => import('@/view/admin/homepageManagement/HomepageManagement')
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path:'/index',
|
||||
name:'index',
|
||||
|
148
HSLink-front/src/util/dom.js
Normal file
148
HSLink-front/src/util/dom.js
Normal file
@ -0,0 +1,148 @@
|
||||
export const on = ({el, type, fn}) => {
|
||||
if (typeof window) {
|
||||
if (window.addEventListener) {
|
||||
el.addEventListener(type, fn, false)
|
||||
} else {
|
||||
el.attachEvent(`on${type}`, fn)
|
||||
}
|
||||
}
|
||||
}
|
||||
export const off = ({el, type, fn}) => {
|
||||
if (typeof window) {
|
||||
if (window.addEventListener) {
|
||||
el.removeEventListener(type, fn)
|
||||
} else {
|
||||
el.detachEvent(`on${type}`, fn)
|
||||
}
|
||||
}
|
||||
}
|
||||
export const once = ({el, type, fn}) => {
|
||||
const hyFn = (event) => {
|
||||
try {
|
||||
fn(event)
|
||||
}
|
||||
finally {
|
||||
off({el, type, fn: hyFn})
|
||||
}
|
||||
}
|
||||
on({el, type, fn: hyFn})
|
||||
}
|
||||
// 最后一个
|
||||
export const fbTwice = ({fn, time = 300}) => {
|
||||
let [cTime, k] = [null, null]
|
||||
// 获取当前时间
|
||||
const getTime = () => new Date().getTime()
|
||||
// 混合函数
|
||||
const hyFn = () => {
|
||||
const ags = argments
|
||||
return () => {
|
||||
clearTimeout(k)
|
||||
k = cTime = null
|
||||
fn(...ags)
|
||||
}
|
||||
}
|
||||
return () => {
|
||||
if (cTime == null) {
|
||||
k = setTimeout(hyFn(...arguments), time)
|
||||
cTime = getTime()
|
||||
} else {
|
||||
if ( getTime() - cTime < 0) {
|
||||
// 清除之前的函数堆 ---- 重新记录
|
||||
clearTimeout(k)
|
||||
k = null
|
||||
cTime = getTime()
|
||||
k = setTimeout(hyFn(...arguments), time)
|
||||
}
|
||||
}}
|
||||
}
|
||||
export const contains = function(parentNode, childNode) {
|
||||
if (parentNode.contains) {
|
||||
return parentNode != childNode && parentNode.contains(childNode)
|
||||
} else {
|
||||
return !!(parentNode.compareDocumentPosition(childNode) & 16)
|
||||
}
|
||||
}
|
||||
export const addClass = function (el, className) {
|
||||
if (typeof el !== "object") {
|
||||
console.log('el is not elem')
|
||||
return null
|
||||
}
|
||||
let classList = el['className']
|
||||
classList = classList === '' ? [] : classList.split(/\s+/)
|
||||
if (classList.indexOf(className) === -1) {
|
||||
classList.push(className)
|
||||
el.className = classList.join(' ')
|
||||
} else {
|
||||
console.warn('warn className current')
|
||||
}
|
||||
}
|
||||
export const removeClass = function (el, className) {
|
||||
let classList = el['className']
|
||||
classList = classList === '' ? [] : classList.split(/\s+/)
|
||||
classList = classList.filter(item => {
|
||||
return item !== className
|
||||
})
|
||||
el.className = classList.join(' ')
|
||||
}
|
||||
export const delay = ({fn, time}) => {
|
||||
let oT = null
|
||||
let k = null
|
||||
return () => {
|
||||
// 当前时间
|
||||
let cT = new Date().getTime()
|
||||
const fixFn = () => {
|
||||
k = oT = null
|
||||
fn()
|
||||
}
|
||||
if (k === null) {
|
||||
oT = cT
|
||||
k = setTimeout(fixFn, time)
|
||||
return
|
||||
}
|
||||
if (cT - oT < time) {
|
||||
oT = cT
|
||||
clearTimeout(k)
|
||||
k = setTimeout(fixFn, time)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
export const Event = function () {
|
||||
// 类型
|
||||
this.typeList = {}
|
||||
}
|
||||
Event.prototype.on = function ({type, fn}){
|
||||
if (this.typeList.hasOwnProperty(type)) {
|
||||
this.typeList[type].push(fn)
|
||||
} else {
|
||||
this.typeList[type] = []
|
||||
this.typeList[type].push(fn)
|
||||
}
|
||||
}
|
||||
Event.prototype.off = function({type, fn}) {
|
||||
if (this.typeList.hasOwnProperty(type)) {
|
||||
let list = this.typeList[type]
|
||||
let index = list.indexOf(fn)
|
||||
if (index !== -1 ) {
|
||||
list.splice(index, 1)
|
||||
}
|
||||
|
||||
} else {
|
||||
console.warn('not has this type')
|
||||
}
|
||||
}
|
||||
Event.prototype.once = function ({type, fn}) {
|
||||
const fixFn = () => {
|
||||
fn()
|
||||
this.off({type, fn: fixFn})
|
||||
}
|
||||
this.on({type, fn: fixFn})
|
||||
}
|
||||
Event.prototype.trigger = function (type){
|
||||
if (this.typeList.hasOwnProperty(type)) {
|
||||
this.typeList[type].forEach(fn => {
|
||||
fn()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
219
HSLink-front/src/view/admin/Admin.vue
Normal file
219
HSLink-front/src/view/admin/Admin.vue
Normal file
@ -0,0 +1,219 @@
|
||||
<template>
|
||||
<el-container>
|
||||
<el-header>
|
||||
<div id="header">
|
||||
<div class="date default-color">{{date}}</div>
|
||||
<div class="function">
|
||||
<span class="pointer special-font-blue " v-if="!isLogin" @click="login">登录</span>
|
||||
<span class="pointer special-font-blue " v-if="isLogin" @click="goPersonalInfo(userInfo.user_id)">欢迎:{{userInfo.real_name}}({{userInfo.user_type}})</span>
|
||||
<span class="pointer special-font-blue " v-if="isLogin" @click="cancellation">注销</span>
|
||||
<el-divider direction="vertical"></el-divider>
|
||||
<span class="pointer special-font-blue" @click="service">客服中心</span>
|
||||
<el-divider direction="vertical"></el-divider>
|
||||
<span class="pointer special-font-blue" @click="opinion">用户意见</span>
|
||||
<el-divider direction="vertical"></el-divider>
|
||||
<span class="pointer special-font-blue" v-if="!isLogin" @click="register">免费注册</span>
|
||||
<el-divider direction="vertical" v-if="!isLogin"></el-divider>
|
||||
<span class="pointer special-font-blue" v-if="isLogin" @click="forget">忘记密码</span>
|
||||
<el-divider direction="vertical" v-if="isLogin"></el-divider>
|
||||
<span class="pointer special-font-blue" @click="help">帮助中心</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="title">后台管理</div>
|
||||
</el-header>
|
||||
<el-container class="second">
|
||||
<el-aside>
|
||||
<el-menu
|
||||
default-active="1"
|
||||
class="el-menu-vertical-demo">
|
||||
<el-menu-item index="1" @click="goToArticleReview">文章审核</el-menu-item>
|
||||
<el-menu-item index="2" @click="goToPersonnelManagement">人员管理</el-menu-item>
|
||||
<el-menu-item index="3" @click="goToHomepageManagement">首页管理</el-menu-item>
|
||||
<el-menu-item index="4"disabled>更多···</el-menu-item>
|
||||
</el-menu>
|
||||
</el-aside>
|
||||
<el-main>
|
||||
<router-view></router-view>
|
||||
</el-main>
|
||||
</el-container>
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getDate } from '../../assets/js/public.js'
|
||||
export default {
|
||||
data() {
|
||||
return{
|
||||
date: '',
|
||||
isLogin: false,
|
||||
userInfo: {
|
||||
real_name: '',
|
||||
user_type: '',
|
||||
},
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
let userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
|
||||
if (userInfo === '' || userInfo === null) {
|
||||
|
||||
} else {
|
||||
this.isLogin = true;
|
||||
this.userInfo = userInfo;
|
||||
}
|
||||
setInterval(()=>{
|
||||
let day2 = new Date();
|
||||
day2.setTime(day2.getTime());
|
||||
this.date = day2.getFullYear()+"年" + (day2.getMonth()+1<10? "0"+(day2.getMonth()+1):day2.getMonth()+1)
|
||||
+ "月" + (day2.getDate()<10?"0"+day2.getDate():day2.getDate())+'日 星期'+"日一二三四五六".charAt(new Date().getDay())
|
||||
+" | "+(day2.getHours()<10?"0"+day2.getHours():day2.getHours())+"时"+(day2.getMinutes()<10?"0"
|
||||
+day2.getMinutes():day2.getMinutes())+"分"+(day2.getSeconds()<10?"0"+day2.getSeconds():day2.getSeconds())+"秒";},1000)
|
||||
},
|
||||
methods:{
|
||||
//跳转文章审核
|
||||
goToArticleReview() {
|
||||
this.$router.push({name: "articlereview"})
|
||||
},
|
||||
//跳转人员管理
|
||||
goToPersonnelManagement() {
|
||||
this.$router.push({name: "personnelmanagement"})
|
||||
},
|
||||
//跳转首页管理
|
||||
goToHomepageManagement() {
|
||||
this.$router.push({name: "homepagemanagement"})
|
||||
},
|
||||
timingTask(userId) {
|
||||
this.$ajax.post("/hs/timingTask",{userId:userId},r=>{
|
||||
console.log(r)
|
||||
})
|
||||
},
|
||||
goPersonalInfo(userId) {
|
||||
sessionStorage.setItem("userId",userId);
|
||||
this.$router.push({name: 'personalinfo'});
|
||||
this.$refs.child.getUserInfo();
|
||||
},
|
||||
goMore() {
|
||||
this.$message({
|
||||
message:"期待更多内容",
|
||||
})
|
||||
|
||||
},
|
||||
help() {
|
||||
this.$router.push({
|
||||
name: "help",
|
||||
})
|
||||
},
|
||||
forget() {
|
||||
this.$message("请联系管理员重置密码")
|
||||
},
|
||||
register() {
|
||||
this.$router.push({
|
||||
name: "homepage",
|
||||
params: {
|
||||
type: "register"
|
||||
}
|
||||
})
|
||||
},
|
||||
opinion() {
|
||||
this.$message('用户意见请发邮箱至:617594538@qq.com')
|
||||
},
|
||||
service() {
|
||||
this.$message('客服中心请拨打:15006732580')
|
||||
},
|
||||
login() {
|
||||
this.$router.push({
|
||||
name: "login"
|
||||
})
|
||||
},
|
||||
cancellation() {
|
||||
this.$confirm('确认退出?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
sessionStorage.setItem("userInfo","");
|
||||
this.$router.push({
|
||||
name: "login"
|
||||
})
|
||||
// location.reload()
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '已取消退出'
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.title{
|
||||
position: absolute;
|
||||
top: 3.5rem;
|
||||
left: 23.5rem;
|
||||
font-size: 2rem;
|
||||
font-weight: bold;
|
||||
color: #ADDFFA;
|
||||
background: #FFFFFF;
|
||||
padding: 0.5rem 2rem;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
.el-container{
|
||||
/*height: 100%;*/
|
||||
}
|
||||
.el-menu{
|
||||
border-radius: 5px;
|
||||
}
|
||||
.el-aside{
|
||||
background: #FFF;
|
||||
overflow-x: hidden;
|
||||
width: 10rem!important;
|
||||
margin-top: 1rem;
|
||||
text-align: center;
|
||||
height: 21rem;
|
||||
}
|
||||
.el-radio-group{
|
||||
margin-bottom: 0!important;
|
||||
}
|
||||
.second{
|
||||
background: #EEFCFE;
|
||||
padding: 0 20%;
|
||||
}
|
||||
.user-cancellation{
|
||||
float: right;
|
||||
}
|
||||
.user-info{
|
||||
float: right;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
.el-main{
|
||||
padding: 0;
|
||||
}
|
||||
#tab{
|
||||
background-image: url("../../assets/img/dh-002.gif");
|
||||
padding: 0 20%;
|
||||
height: 2rem;
|
||||
font-size: 0.9rem;
|
||||
line-height: 2rem;
|
||||
|
||||
}
|
||||
#header{
|
||||
font-size: 0.9rem;
|
||||
padding: 0.2rem 0 0.4rem 0;
|
||||
}
|
||||
#header .date{
|
||||
margin-left: 20%;
|
||||
float: left;
|
||||
}
|
||||
#header .function{
|
||||
float: right;
|
||||
margin-right: 20%;
|
||||
}
|
||||
.el-header{
|
||||
height: 7.8rem!important;
|
||||
background-image: url("../../assets/img/title.jpg");
|
||||
background-size: 100%;
|
||||
background-position: 0 2rem;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
</style>
|
76
HSLink-front/src/view/admin/articleReview/ArticleReview.vue
Normal file
76
HSLink-front/src/view/admin/articleReview/ArticleReview.vue
Normal file
@ -0,0 +1,76 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="top">
|
||||
|
||||
</div>
|
||||
<div class="table">
|
||||
<el-table
|
||||
:data="tableData"
|
||||
style="width: 100%">
|
||||
<el-table-column
|
||||
type="index"
|
||||
width="50">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="date"
|
||||
label="日期"
|
||||
width="180">
|
||||
</el-table-column>
|
||||
<el-table-column label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
@click="handleEdit(scope.$index, scope.row)">编辑</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="danger"
|
||||
@click="handleDelete(scope.$index, scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
tableData: [{
|
||||
date: '2016-05-02',
|
||||
name: '王小虎',
|
||||
address: '上海市普陀区金沙江路 1518 弄'
|
||||
}, {
|
||||
date: '2016-05-04',
|
||||
name: '王小虎',
|
||||
address: '上海市普陀区金沙江路 1517 弄'
|
||||
}, {
|
||||
date: '2016-05-01',
|
||||
name: '王小虎',
|
||||
address: '上海市普陀区金沙江路 1519 弄'
|
||||
}, {
|
||||
date: '2016-05-03',
|
||||
name: '王小虎',
|
||||
address: '上海市普陀区金沙江路 1516 弄'
|
||||
}]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleEdit(index, row) {
|
||||
console.log(index, row);
|
||||
},
|
||||
handleDelete(index, row) {
|
||||
console.log(index, row);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page{
|
||||
margin: 1rem;
|
||||
border-radius: 5px;
|
||||
padding: 1rem;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,13 @@
|
||||
<template>
|
||||
<h1>1111</h1>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "HomepageManagement"
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
@ -0,0 +1,37 @@
|
||||
<template>
|
||||
<div id="demo"></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import layui from 'layui';
|
||||
layui.use('table', function(){
|
||||
var table = layui.table;
|
||||
|
||||
//第一个实例
|
||||
table.render({
|
||||
elem: '#demo'
|
||||
,height: 312
|
||||
,url: '192.168.10.29:8048/hs/test' //数据接口
|
||||
,page: true //开启分页
|
||||
,cols: [[ //表头
|
||||
{field: 'id', title: 'ID', width:80, sort: true, fixed: 'left'}
|
||||
,{field: 'username', title: '用户名', width:80}
|
||||
,{field: 'sex', title: '性别', width:80, sort: true}
|
||||
,{field: 'city', title: '城市', width:80}
|
||||
,{field: 'sign', title: '签名', width: 177}
|
||||
,{field: 'experience', title: '积分', width: 80, sort: true}
|
||||
,{field: 'score', title: '评分', width: 80, sort: true}
|
||||
,{field: 'classify', title: '职业', width: 80}
|
||||
,{field: 'wealth', title: '财富', width: 135, sort: true}
|
||||
]]
|
||||
});
|
||||
|
||||
});
|
||||
export default {
|
||||
name: "PersonnelManagement"
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
83
HSLink-front/src/view/upload.vue
Normal file
83
HSLink-front/src/view/upload.vue
Normal file
@ -0,0 +1,83 @@
|
||||
<template>
|
||||
<div id="upload">
|
||||
<el-upload
|
||||
class="upload-demo"
|
||||
action="http://127.0.0.1:8048/hs/upload"
|
||||
:on-preview="handlePreview"
|
||||
:on-remove="handleRemove"
|
||||
:file-list="fileList"
|
||||
list-type="picture">
|
||||
<el-button size="small" type="primary">点击上传</el-button>
|
||||
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
|
||||
</el-upload>
|
||||
<div class="img">
|
||||
<img v-for="(item,index) in fileList" :src="item.path" height="100" width="100"/>
|
||||
</div>
|
||||
<el-button @click="fileUpload">
|
||||
下载
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
fileList: []
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.getPhoto();
|
||||
},
|
||||
methods: {
|
||||
//下载
|
||||
fileUpload() {
|
||||
this.$axios(
|
||||
{
|
||||
method: 'post',
|
||||
url: 'http://127.0.0.1:8048/hs/fileDownload',
|
||||
params: {
|
||||
fileId: '111'
|
||||
},
|
||||
responseType: 'blob'//注意:一定要定义返回数据类型,否则获取到的文件流无法解析,下载的文件会无数据
|
||||
}).then(res=>{
|
||||
this.download(res.data,"text.png")
|
||||
}
|
||||
)
|
||||
},
|
||||
// 下载文件
|
||||
download (data,fileName) {
|
||||
if (!data) {
|
||||
return
|
||||
}
|
||||
let url = window.URL.createObjectURL(new Blob([data]));
|
||||
let link = document.createElement('a');
|
||||
link.style.display = 'none';
|
||||
link.href = url;
|
||||
link.setAttribute('download', fileName);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
},
|
||||
//获取图片列表
|
||||
getPhoto() {
|
||||
this.$ajax.post('/hs/getFileList',{},r=>{
|
||||
this.fileList = [];
|
||||
for (let i = 0; i < r.fileList.length; i++) {
|
||||
this.fileList.push({path: require('../assets/file/'+r.fileList[i].fileEncryption)})
|
||||
}
|
||||
})
|
||||
},
|
||||
handleRemove(file, fileList) {
|
||||
console.log(file, fileList);
|
||||
},
|
||||
handlePreview(file) {
|
||||
console.log(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.upload-demo >>> ul{
|
||||
display: none!important;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user