mirror of https://github.com/elunez/eladmin
完成了本地存储功能,用户头像存储方式改为本地
parent
76242d4d67
commit
a71243d9eb
|
@ -61,6 +61,7 @@ public class RedisConfig extends CachingConfigurerSupport {
|
|||
// 建议使用这种方式,小范围指定白名单
|
||||
ParserConfig.getGlobalInstance().addAccept("me.zhengjie.domain");
|
||||
ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.system.service.dto");
|
||||
ParserConfig.getGlobalInstance().addAccept("me.zhengjie.service.dto");
|
||||
ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.system.domain");
|
||||
ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.quartz.domain");
|
||||
ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.monitor.domain");
|
||||
|
|
|
@ -4,12 +4,16 @@ import cn.hutool.core.io.IoUtil;
|
|||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import cn.hutool.poi.excel.ExcelWriter;
|
||||
import me.zhengjie.exception.BadRequestException;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -107,7 +111,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||
* @param size
|
||||
* @return
|
||||
*/
|
||||
public static String getSize(int size){
|
||||
public static String getSize(long size){
|
||||
String resultSize = "";
|
||||
if (size / GB >= 1) {
|
||||
//如果当前Byte的值大于等于1GB
|
||||
|
@ -147,6 +151,47 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将文件名解析成文件的上传路径
|
||||
*
|
||||
* @param file
|
||||
* @param filePath
|
||||
* @return 上传到服务器的文件名
|
||||
*/
|
||||
public static File upload(MultipartFile file, String filePath) {
|
||||
Date date = new Date();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddhhmmssS");
|
||||
String name = getFileNameNoEx(file.getOriginalFilename());
|
||||
String suffix = getExtensionName(file.getOriginalFilename());
|
||||
String nowStr = "-" + format.format(date);
|
||||
try {
|
||||
String fileName = name + nowStr + "." + suffix;
|
||||
String path = filePath + fileName;
|
||||
File dest = new File(path);
|
||||
// 检测是否存在目录
|
||||
if (!dest.getParentFile().exists()) {
|
||||
dest.getParentFile().mkdirs();// 新建文件夹
|
||||
}
|
||||
String d = dest.getPath();
|
||||
file.transferTo(dest);// 文件写入
|
||||
return dest;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String fileToBase64(File file) throws Exception {
|
||||
FileInputStream inputFile = new FileInputStream(file);
|
||||
String base64 =null;
|
||||
byte[] buffer = new byte[(int)file.length()];
|
||||
inputFile.read(buffer);
|
||||
inputFile.close();
|
||||
base64=new BASE64Encoder().encode(buffer);
|
||||
String encoded = base64.replaceAll("[\\s*\t\n\r]", "");
|
||||
return encoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
* @param list
|
||||
|
@ -174,4 +219,26 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||
//此处记得关闭输出Servlet流
|
||||
IoUtil.close(out);
|
||||
}
|
||||
|
||||
public static String getFileType(String type) {
|
||||
String documents = "txt doc pdf ppt pps xlsx xls";
|
||||
String music = "mp3 wav wma mpa ram ra aac aif m4a";
|
||||
String video = "avi mpg mpe mpeg asf wmv mov qt rm mp4 flv m4v webm ogv ogg";
|
||||
String image = "bmp dib pcp dif wmf gif jpg tif eps psd cdr iff tga pcd mpt png jpeg";
|
||||
if(image.indexOf(type) != -1){
|
||||
return "图片";
|
||||
} else if(documents.indexOf(type) != -1){
|
||||
return "文档";
|
||||
} else if(music.indexOf(type) != -1){
|
||||
return "音乐";
|
||||
} else if(video.indexOf(type) != -1){
|
||||
return "视频";
|
||||
} else return "其他";
|
||||
}
|
||||
|
||||
public static void checkSize(long maxSize, long size) {
|
||||
if(size > (maxSize * 1024 * 1024)){
|
||||
throw new BadRequestException("文件超出规定大小");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package me.zhengjie.config;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
|
@ -25,6 +26,12 @@ import java.util.List;
|
|||
@EnableWebMvc
|
||||
public class ConfigurerAdapter implements WebMvcConfigurer {
|
||||
|
||||
@Value("${file.path}")
|
||||
private String path;
|
||||
|
||||
@Value("${file.avatar}")
|
||||
private String avatar;
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
|
@ -35,27 +42,12 @@ public class ConfigurerAdapter implements WebMvcConfigurer {
|
|||
|
||||
}
|
||||
|
||||
// 可解决Long 类型在 前端精度丢失的问题, 如不想全局 直接添加注解 @JsonSerialize(using= ToStringSerializer.class) 到相应的字段
|
||||
|
||||
// @Override
|
||||
// public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
//
|
||||
// MappingJackson2HttpMessageConverter jackson2HttpMessageConverter =
|
||||
// new MappingJackson2HttpMessageConverter();
|
||||
//
|
||||
// ObjectMapper objectMapper = new ObjectMapper();
|
||||
// SimpleModule simpleModule = new SimpleModule();
|
||||
// simpleModule.addSerializer(BigInteger.class, ToStringSerializer.instance);
|
||||
// simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
|
||||
// simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
|
||||
// objectMapper.registerModule(simpleModule);
|
||||
// jackson2HttpMessageConverter.setObjectMapper(objectMapper);
|
||||
// converters.add(jackson2HttpMessageConverter);
|
||||
// converters.add(new StringHttpMessageConverter(Charset.forName("UTF-8")));
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
String avatarUtl = "file:" + avatar.replace("\\","/");
|
||||
String pathUtl = "file:" + path.replace("\\","/");
|
||||
registry.addResourceHandler("/avatar/**").addResourceLocations(avatarUtl).setCachePeriod(0);
|
||||
registry.addResourceHandler("/file/**").addResourceLocations(pathUtl).setCachePeriod(0);
|
||||
registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/").setCachePeriod(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,6 +106,11 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||
|
||||
// 接口限流测试
|
||||
.antMatchers("/test/**").anonymous()
|
||||
// 文件
|
||||
.antMatchers("/avatar/**").anonymous()
|
||||
.antMatchers("/file/**").anonymous()
|
||||
|
||||
// 放行OPTIONS请求
|
||||
.antMatchers(HttpMethod.OPTIONS, "/**").anonymous()
|
||||
|
||||
.antMatchers("/druid/**").anonymous()
|
||||
|
|
|
@ -31,7 +31,9 @@ public class User implements Serializable {
|
|||
@Column(unique = true)
|
||||
private String username;
|
||||
|
||||
private String avatar;
|
||||
@OneToOne
|
||||
@JoinColumn(name = "avatar_id")
|
||||
private UserAvatar userAvatar;
|
||||
|
||||
@NotBlank
|
||||
@Pattern(regexp = "([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}",message = "格式错误")
|
||||
|
@ -69,7 +71,6 @@ public class User implements Serializable {
|
|||
return "User{" +
|
||||
"id=" + id +
|
||||
", username='" + username + '\'' +
|
||||
", avatar='" + avatar + '\'' +
|
||||
", email='" + email + '\'' +
|
||||
", enabled=" + enabled +
|
||||
", password='" + password + '\'' +
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package me.zhengjie.modules.system.domain;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019年9月7日 16:16:59
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "user_avatar")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class UserAvatar {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String realName;
|
||||
|
||||
private String path;
|
||||
|
||||
private String size;
|
||||
|
||||
public UserAvatar(UserAvatar userAvatar,String realName, String path, String size) {
|
||||
this.id = ObjectUtil.isNotEmpty(userAvatar) ? userAvatar.getId() : null;
|
||||
this.realName = realName;
|
||||
this.path = path;
|
||||
this.size = size;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package me.zhengjie.modules.system.repository;
|
||||
|
||||
import me.zhengjie.modules.system.domain.UserAvatar;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-11-22
|
||||
*/
|
||||
public interface UserAvatarRepository extends JpaRepository<UserAvatar, Long>, JpaSpecificationExecutor {
|
||||
|
||||
}
|
|
@ -155,8 +155,7 @@ public class UserController {
|
|||
*/
|
||||
@PostMapping(value = "/users/updateAvatar")
|
||||
public ResponseEntity updateAvatar(@RequestParam MultipartFile file){
|
||||
Picture picture = pictureService.upload(file, SecurityUtils.getUsername());
|
||||
userService.updateAvatar(SecurityUtils.getUsername(),picture.getUrl());
|
||||
userService.updateAvatar(file);
|
||||
return new ResponseEntity(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.springframework.cache.annotation.CacheConfig;
|
|||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
@ -67,11 +68,10 @@ public interface UserService {
|
|||
|
||||
/**
|
||||
* 修改头像
|
||||
* @param username
|
||||
* @param url
|
||||
* @param file
|
||||
*/
|
||||
@CacheEvict(allEntries = true)
|
||||
void updateAvatar(String username, String url);
|
||||
void updateAvatar(MultipartFile file);
|
||||
|
||||
/**
|
||||
* 修改邮箱
|
||||
|
|
|
@ -197,15 +197,13 @@ public class MenuServiceImpl implements MenuService {
|
|||
if (menuDTO!=null){
|
||||
List<MenuDTO> menuDTOList = menuDTO.getChildren();
|
||||
MenuVo menuVo = new MenuVo();
|
||||
menuVo.setName(ObjectUtil.isNotEmpty(menuDTO.getComponentName()) ? menuDTO.getComponentName() : RandomUtil.randomString(5));
|
||||
menuVo.setPath(menuDTO.getPath());
|
||||
menuVo.setName(ObjectUtil.isNotEmpty(menuDTO.getComponentName()) ? menuDTO.getComponentName() : menuDTO.getName());
|
||||
// 一级目录需要加斜杠,不然会报警告
|
||||
menuVo.setPath(menuDTO.getPid() == 0 ? "/" + menuDTO.getPath() :menuDTO.getPath());
|
||||
menuVo.setHidden(menuDTO.getHidden());
|
||||
|
||||
// 如果不是外链
|
||||
if(!menuDTO.getIFrame()){
|
||||
if(menuDTO.getPid() == 0){
|
||||
//一级目录需要加斜杠,不然访问 会跳转404页面
|
||||
menuVo.setPath("/" + menuDTO.getPath());
|
||||
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent())?"Layout":menuDTO.getComponent());
|
||||
}else if(!StrUtil.isEmpty(menuDTO.getComponent())){
|
||||
menuVo.setComponent(menuDTO.getComponent());
|
||||
|
|
|
@ -7,24 +7,27 @@ import me.zhengjie.modules.monitor.service.RedisService;
|
|||
import me.zhengjie.modules.system.domain.User;
|
||||
import me.zhengjie.exception.EntityExistException;
|
||||
import me.zhengjie.exception.EntityNotFoundException;
|
||||
import me.zhengjie.modules.system.domain.UserAvatar;
|
||||
import me.zhengjie.modules.system.repository.UserAvatarRepository;
|
||||
import me.zhengjie.modules.system.repository.UserRepository;
|
||||
import me.zhengjie.modules.system.service.UserService;
|
||||
import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
|
||||
import me.zhengjie.modules.system.service.dto.UserDTO;
|
||||
import me.zhengjie.modules.system.service.dto.UserQueryCriteria;
|
||||
import me.zhengjie.modules.system.service.mapper.UserMapper;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.utils.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -46,6 +49,12 @@ public class UserServiceImpl implements UserService {
|
|||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private UserAvatarRepository userAvatarRepository;
|
||||
|
||||
@Value("${file.avatar}")
|
||||
private String avatar;
|
||||
|
||||
@Override
|
||||
public Object queryAll(UserQueryCriteria criteria, Pageable pageable) {
|
||||
Page<User> page = userRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
|
@ -79,7 +88,6 @@ public class UserServiceImpl implements UserService {
|
|||
|
||||
// 默认密码 123456,此密码是加密后的字符
|
||||
resources.setPassword("e10adc3949ba59abbe56e057f20f883e");
|
||||
resources.setAvatar("https://i.loli.net/2019/04/04/5ca5b971e1548.jpeg");
|
||||
return userMapper.toDto(userRepository.save(resources));
|
||||
}
|
||||
|
||||
|
@ -149,8 +157,20 @@ public class UserServiceImpl implements UserService {
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateAvatar(String username, String url) {
|
||||
userRepository.updateAvatar(username,url);
|
||||
public void updateAvatar(MultipartFile multipartFile) {
|
||||
User user = userRepository.findByUsername(SecurityUtils.getUsername());
|
||||
UserAvatar userAvatar = user.getUserAvatar();
|
||||
String oldPath = "";
|
||||
if(userAvatar != null){
|
||||
oldPath = userAvatar.getPath();
|
||||
}
|
||||
File file = FileUtil.upload(multipartFile, avatar);
|
||||
userAvatar = userAvatarRepository.save(new UserAvatar(userAvatar,file.getName(), file.getPath(), FileUtil.getSize(multipartFile.getSize())));
|
||||
user.setUserAvatar(userAvatar);
|
||||
userRepository.save(user);
|
||||
if(StringUtils.isNotBlank(oldPath)){
|
||||
FileUtil.del(oldPath);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,8 +4,11 @@ import me.zhengjie.modules.system.domain.User;
|
|||
import me.zhengjie.mapper.EntityMapper;
|
||||
import me.zhengjie.modules.system.service.dto.UserDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-11-23
|
||||
|
@ -13,4 +16,6 @@ import org.mapstruct.ReportingPolicy;
|
|||
@Mapper(componentModel = "spring",uses = {RoleMapper.class, DeptMapper.class, JobMapper.class},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface UserMapper extends EntityMapper<UserDTO, User> {
|
||||
|
||||
@Mapping(source = "user.userAvatar.realName",target = "avatar")
|
||||
UserDTO toDto(User user);
|
||||
}
|
||||
|
|
|
@ -59,4 +59,12 @@ generator:
|
|||
|
||||
#是否开启 swagger-ui
|
||||
swagger:
|
||||
enabled: true
|
||||
enabled: true
|
||||
|
||||
# 文件存储路径
|
||||
file:
|
||||
path: C:\eladmin\file\
|
||||
avatar: C:\eladmin\avatar\
|
||||
# 文件大小 /M
|
||||
maxSize: 100
|
||||
avatarMaxSize: 5
|
|
@ -68,4 +68,12 @@ generator:
|
|||
|
||||
#是否开启 swagger-ui
|
||||
swagger:
|
||||
enabled: false
|
||||
enabled: false
|
||||
|
||||
# 文件存储路径
|
||||
file:
|
||||
path: /home/eladmin/file/
|
||||
avatar: /home/eladmin/avatar/
|
||||
# 文件大小 /M
|
||||
maxSize: 100
|
||||
avatarMaxSize: 5
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<el-dialog :append-to-body="true" :visible.sync="dialog" :title="isAdd ? '新增' : '编辑'" width="500px">
|
||||
<el-dialog :append-to-body="true" :close-on-click-modal="false" :before-close="cancel" :visible.sync="dialog" :title="isAdd ? '新增' : '编辑'" width="500px">
|
||||
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
|
||||
<#if columns??>
|
||||
<#list columns as column>
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
package me.zhengjie.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
import org.hibernate.annotations.UpdateTimestamp;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="local_storage")
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LocalStorage implements Serializable {
|
||||
|
||||
// ID
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
// 真实文件名
|
||||
@Column(name = "real_name")
|
||||
private String realName;
|
||||
|
||||
// 文件名
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
// 后缀
|
||||
@Column(name = "suffix")
|
||||
private String suffix;
|
||||
|
||||
// 路径
|
||||
@Column(name = "path")
|
||||
private String path;
|
||||
|
||||
// 类型
|
||||
@Column(name = "type")
|
||||
private String type;
|
||||
|
||||
// 大小
|
||||
@Column(name = "size")
|
||||
private String size;
|
||||
|
||||
// 操作人
|
||||
@Column(name = "operate")
|
||||
private String operate;
|
||||
|
||||
// 创建日期
|
||||
@Column(name = "create_time")
|
||||
@CreationTimestamp
|
||||
private Timestamp createTime;
|
||||
|
||||
// 修改日期
|
||||
@Column(name = "update_time")
|
||||
@UpdateTimestamp
|
||||
private Timestamp updateTime;
|
||||
|
||||
public LocalStorage(String realName,String name, String suffix, String path, String type, String size, String operate) {
|
||||
this.realName = realName;
|
||||
this.name = name;
|
||||
this.suffix = suffix;
|
||||
this.path = path;
|
||||
this.type = type;
|
||||
this.size = size;
|
||||
this.operate = operate;
|
||||
}
|
||||
|
||||
public void copy(LocalStorage source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package me.zhengjie.repository;
|
||||
|
||||
import me.zhengjie.domain.LocalStorage;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
public interface LocalStorageRepository extends JpaRepository<LocalStorage, Long>, JpaSpecificationExecutor {
|
||||
}
|
|
@ -2,10 +2,16 @@ package me.zhengjie.repository;
|
|||
|
||||
import me.zhengjie.domain.QiniuConfig;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
public interface QiNiuConfigRepository extends JpaRepository<QiniuConfig,Long> {
|
||||
|
||||
@Modifying
|
||||
@Query(value = "update qiniu_content set type = ?1", nativeQuery = true)
|
||||
void update(String type);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package me.zhengjie.rest;
|
||||
|
||||
import me.zhengjie.aop.log.Log;
|
||||
import me.zhengjie.domain.LocalStorage;
|
||||
import me.zhengjie.service.LocalStorageService;
|
||||
import me.zhengjie.service.dto.LocalStorageQueryCriteria;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@Api(tags = "本地存储管理")
|
||||
@RestController
|
||||
@RequestMapping("api")
|
||||
public class LocalStorageController {
|
||||
|
||||
@Autowired
|
||||
private LocalStorageService localStorageService;
|
||||
|
||||
@ApiOperation(value = "查询文件")
|
||||
@GetMapping(value = "/localStorage")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_SELECT')")
|
||||
public ResponseEntity getLocalStorages(LocalStorageQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity(localStorageService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "上传文件")
|
||||
@PostMapping(value = "/localStorage")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_CREATE')")
|
||||
public ResponseEntity create(@RequestParam String name, @RequestParam("file") MultipartFile file){
|
||||
return new ResponseEntity(localStorageService.create(name, file),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改文件")
|
||||
@PutMapping(value = "/localStorage")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_EDIT')")
|
||||
public ResponseEntity update(@Validated @RequestBody LocalStorage resources){
|
||||
localStorageService.update(resources);
|
||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除文件")
|
||||
@DeleteMapping(value = "/localStorage/{id}")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_DELETE')")
|
||||
public ResponseEntity delete(@PathVariable Long id){
|
||||
localStorageService.delete(id);
|
||||
return new ResponseEntity(HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除多张图片
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@Log("删除图片")
|
||||
@DeleteMapping(value = "/localStorage")
|
||||
public ResponseEntity deleteAll(@RequestBody Long[] ids) {
|
||||
localStorageService.deleteAll(ids);
|
||||
return new ResponseEntity(HttpStatus.OK);
|
||||
}
|
||||
}
|
|
@ -38,6 +38,7 @@ public class QiniuController {
|
|||
@PutMapping(value = "/qiNiuConfig")
|
||||
public ResponseEntity emailConfig(@Validated @RequestBody QiniuConfig qiniuConfig){
|
||||
qiNiuService.update(qiniuConfig);
|
||||
qiNiuService.update(qiniuConfig.getType());
|
||||
return new ResponseEntity(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package me.zhengjie.service;
|
||||
|
||||
import me.zhengjie.domain.LocalStorage;
|
||||
import me.zhengjie.service.dto.LocalStorageDTO;
|
||||
import me.zhengjie.service.dto.LocalStorageQueryCriteria;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@CacheConfig(cacheNames = "localStorage")
|
||||
public interface LocalStorageService {
|
||||
|
||||
/**
|
||||
* queryAll 分页
|
||||
* @param criteria
|
||||
* @param pageable
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(keyGenerator = "keyGenerator")
|
||||
Object queryAll(LocalStorageQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* queryAll 不分页
|
||||
* @param criteria
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(keyGenerator = "keyGenerator")
|
||||
public Object queryAll(LocalStorageQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* findById
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(key = "#p0")
|
||||
LocalStorageDTO findById(Long id);
|
||||
|
||||
/**
|
||||
* create
|
||||
* @param name
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@CacheEvict(allEntries = true)
|
||||
LocalStorageDTO create(String name, MultipartFile file);
|
||||
|
||||
/**
|
||||
* update
|
||||
* @param resources
|
||||
*/
|
||||
@CacheEvict(allEntries = true)
|
||||
void update(LocalStorage resources);
|
||||
|
||||
/**
|
||||
* delete
|
||||
* @param id
|
||||
*/
|
||||
@CacheEvict(allEntries = true)
|
||||
void delete(Long id);
|
||||
|
||||
@CacheEvict(allEntries = true)
|
||||
void deleteAll(Long[] ids);
|
||||
}
|
|
@ -8,6 +8,7 @@ import org.springframework.cache.annotation.CacheEvict;
|
|||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
|
@ -89,4 +90,7 @@ public interface QiNiuService {
|
|||
*/
|
||||
@CacheEvict(allEntries = true)
|
||||
void deleteAll(Long[] ids, QiniuConfig config);
|
||||
|
||||
@CacheEvict(allEntries = true)
|
||||
void update(String type);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package me.zhengjie.service.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@Data
|
||||
public class LocalStorageDTO implements Serializable {
|
||||
|
||||
// ID
|
||||
private Long id;
|
||||
|
||||
private String realName;
|
||||
|
||||
// 文件名
|
||||
private String name;
|
||||
|
||||
// 后缀
|
||||
private String suffix;
|
||||
|
||||
// 类型
|
||||
private String type;
|
||||
|
||||
// 大小
|
||||
private String size;
|
||||
|
||||
// 操作人
|
||||
private String operate;
|
||||
|
||||
// 创建日期
|
||||
private Timestamp createTime;
|
||||
|
||||
// 修改日期
|
||||
private Timestamp updateTime;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package me.zhengjie.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@Data
|
||||
public class LocalStorageQueryCriteria{
|
||||
|
||||
// 模糊
|
||||
@Query(blurry = "name,suffix,type,operate,size")
|
||||
private String blurry;
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
package me.zhengjie.service.impl;
|
||||
|
||||
import me.zhengjie.domain.LocalStorage;
|
||||
import me.zhengjie.exception.BadRequestException;
|
||||
import me.zhengjie.utils.*;
|
||||
import me.zhengjie.repository.LocalStorageRepository;
|
||||
import me.zhengjie.service.LocalStorageService;
|
||||
import me.zhengjie.service.dto.LocalStorageDTO;
|
||||
import me.zhengjie.service.dto.LocalStorageQueryCriteria;
|
||||
import me.zhengjie.service.mapper.LocalStorageMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@Service
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
|
||||
@Autowired
|
||||
private LocalStorageRepository localStorageRepository;
|
||||
|
||||
@Autowired
|
||||
private LocalStorageMapper localStorageMapper;
|
||||
|
||||
@Value("${file.path}")
|
||||
private String path;
|
||||
|
||||
@Value("${file.maxSize}")
|
||||
private long maxSize;
|
||||
|
||||
@Override
|
||||
public Object queryAll(LocalStorageQueryCriteria criteria, Pageable pageable){
|
||||
Page<LocalStorage> page = localStorageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(localStorageMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object queryAll(LocalStorageQueryCriteria criteria){
|
||||
return localStorageMapper.toDto(localStorageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalStorageDTO findById(Long id) {
|
||||
Optional<LocalStorage> localStorage = localStorageRepository.findById(id);
|
||||
ValidationUtil.isNull(localStorage,"LocalStorage","id",id);
|
||||
return localStorageMapper.toDto(localStorage.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public LocalStorageDTO create(String name, MultipartFile multipartFile) {
|
||||
FileUtil.checkSize(maxSize, multipartFile.getSize());
|
||||
String suffix = FileUtil.getExtensionName(multipartFile.getOriginalFilename());
|
||||
String type = FileUtil.getFileType(suffix);
|
||||
File file = FileUtil.upload(multipartFile, path + type + File.separator);
|
||||
try {
|
||||
name = StringUtils.isBlank(name) ? FileUtil.getFileNameNoEx(multipartFile.getOriginalFilename()) : name;
|
||||
LocalStorage localStorage = new LocalStorage(
|
||||
file.getName(),
|
||||
name,
|
||||
suffix,
|
||||
file.getPath(),
|
||||
type,
|
||||
FileUtil.getSize(multipartFile.getSize()),
|
||||
SecurityUtils.getUsername()
|
||||
);
|
||||
return localStorageMapper.toDto(localStorageRepository.save(localStorage));
|
||||
}catch (Exception e){
|
||||
FileUtil.del(file);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
File file = new File("C:\\Users\\Jie\\Pictures\\Saved Pictures\\demo1.jpg");
|
||||
System.out.println(FileUtil.getType(file));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(LocalStorage resources) {
|
||||
Optional<LocalStorage> optionalLocalStorage = localStorageRepository.findById(resources.getId());
|
||||
ValidationUtil.isNull( optionalLocalStorage,"LocalStorage","id",resources.getId());
|
||||
LocalStorage localStorage = optionalLocalStorage.get();
|
||||
localStorage.copy(resources);
|
||||
localStorageRepository.save(localStorage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long id) {
|
||||
LocalStorage storage = localStorageRepository.findById(id).get();
|
||||
FileUtil.del(storage.getPath());
|
||||
localStorageRepository.delete(storage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(Long[] ids) {
|
||||
for (Long id : ids) {
|
||||
LocalStorage storage = localStorageRepository.findById(id).get();
|
||||
FileUtil.del(storage.getPath());
|
||||
localStorageRepository.delete(storage);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -73,11 +73,7 @@ public class QiNiuServiceImpl implements QiNiuService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public QiniuContent upload(MultipartFile file, QiniuConfig qiniuConfig) {
|
||||
|
||||
Long size = maxSize * 1024 * 1024;
|
||||
if(file.getSize() > size){
|
||||
throw new BadRequestException("文件超出规定大小");
|
||||
}
|
||||
FileUtil.checkSize(maxSize, file.getSize());
|
||||
if(qiniuConfig.getId() == null){
|
||||
throw new BadRequestException("请先添加相应配置,再操作");
|
||||
}
|
||||
|
@ -100,7 +96,7 @@ public class QiNiuServiceImpl implements QiNiuService {
|
|||
QiniuContent qiniuContent = new QiniuContent();
|
||||
qiniuContent.setBucket(qiniuConfig.getBucket());
|
||||
qiniuContent.setType(qiniuConfig.getType());
|
||||
qiniuContent.setKey(putRet.key);
|
||||
qiniuContent.setKey(FileUtil.getFileNameNoEx(putRet.key));
|
||||
qiniuContent.setUrl(qiniuConfig.getHost()+"/"+putRet.key);
|
||||
qiniuContent.setSize(FileUtil.getSize(Integer.parseInt(file.getSize()+"")));
|
||||
return qiniuContentRepository.save(qiniuContent);
|
||||
|
@ -170,10 +166,10 @@ public class QiNiuServiceImpl implements QiNiuService {
|
|||
QiniuContent qiniuContent = null;
|
||||
FileInfo[] items = fileListIterator.next();
|
||||
for (FileInfo item : items) {
|
||||
if(qiniuContentRepository.findByKey(item.key) == null){
|
||||
if(qiniuContentRepository.findByKey(FileUtil.getFileNameNoEx(item.key)) == null){
|
||||
qiniuContent = new QiniuContent();
|
||||
qiniuContent.setSize(FileUtil.getSize(Integer.parseInt(item.fsize+"")));
|
||||
qiniuContent.setKey(item.key);
|
||||
qiniuContent.setKey(FileUtil.getFileNameNoEx(item.key));
|
||||
qiniuContent.setType(config.getType());
|
||||
qiniuContent.setBucket(config.getBucket());
|
||||
qiniuContent.setUrl(config.getHost()+"/"+item.key);
|
||||
|
@ -189,4 +185,10 @@ public class QiNiuServiceImpl implements QiNiuService {
|
|||
delete(findByContentId(id), config);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(String type) {
|
||||
qiNiuConfigRepository.update(type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package me.zhengjie.service.mapper;
|
||||
|
||||
import me.zhengjie.mapper.EntityMapper;
|
||||
import me.zhengjie.domain.LocalStorage;
|
||||
import me.zhengjie.service.dto.LocalStorageDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface LocalStorageMapper extends EntityMapper<LocalStorageDTO, LocalStorage> {
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
Target Server Version : 50562
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 27/08/2019 15:46:59
|
||||
Date: 07/09/2019 21:59:47
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
|
@ -77,7 +77,7 @@ CREATE TABLE `dict` (
|
|||
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '字典名称',
|
||||
`remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of dict
|
||||
|
@ -85,6 +85,7 @@ CREATE TABLE `dict` (
|
|||
INSERT INTO `dict` VALUES (1, 'user_status', '用户状态');
|
||||
INSERT INTO `dict` VALUES (4, 'dept_status', '部门状态');
|
||||
INSERT INTO `dict` VALUES (5, 'job_status', '岗位状态');
|
||||
INSERT INTO `dict` VALUES (6, 'tt', 'tt');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for dict_detail
|
||||
|
@ -99,7 +100,7 @@ CREATE TABLE `dict_detail` (
|
|||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `FK5tpkputc6d9nboxojdbgnpmyb`(`dict_id`) USING BTREE,
|
||||
CONSTRAINT `FK5tpkputc6d9nboxojdbgnpmyb` FOREIGN KEY (`dict_id`) REFERENCES `dict` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 15 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 16 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of dict_detail
|
||||
|
@ -110,6 +111,7 @@ INSERT INTO `dict_detail` VALUES (11, '正常', 'true', '1', 4);
|
|||
INSERT INTO `dict_detail` VALUES (12, '停用', 'false', '2', 4);
|
||||
INSERT INTO `dict_detail` VALUES (13, '正常', 'true', '1', 5);
|
||||
INSERT INTO `dict_detail` VALUES (14, '停用', 'false', '2', 5);
|
||||
INSERT INTO `dict_detail` VALUES (15, 'f', 'fdaf', '1', 6);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for email_config
|
||||
|
@ -144,7 +146,7 @@ CREATE TABLE `gen_config` (
|
|||
-- ----------------------------
|
||||
-- Records of gen_config
|
||||
-- ----------------------------
|
||||
INSERT INTO `gen_config` VALUES (1, 'Zheng Jie', b'0', 'eladmin-system', 'me.zhengjie.modules.test', 'E:\\workspace\\me\\front\\eladmin-qt\\src\\views\\test', 'E:\\workspace\\me\\front\\eladmin-qt\\src\\api', NULL);
|
||||
INSERT INTO `gen_config` VALUES (1, 'Zheng Jie', b'0', 'eladmin-tools', 'me.zhengjie', 'E:\\workspace\\me\\front\\eladmin-qt\\src\\views\\tools\\storage\\local', 'E:\\workspace\\me\\front\\eladmin-qt\\src\\api', NULL);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for job
|
||||
|
@ -160,7 +162,7 @@ CREATE TABLE `job` (
|
|||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `FKmvhj0rogastlctflsxf1d6k3i`(`dept_id`) USING BTREE,
|
||||
CONSTRAINT `FKmvhj0rogastlctflsxf1d6k3i` FOREIGN KEY (`dept_id`) REFERENCES `dept` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 24 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 20 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of job
|
||||
|
@ -171,10 +173,24 @@ INSERT INTO `job` VALUES (10, '产品经理', b'0', '2019-03-29 14:55:51', 4, 2)
|
|||
INSERT INTO `job` VALUES (11, '全栈开发', b'1', '2019-03-31 13:39:30', 6, 2);
|
||||
INSERT INTO `job` VALUES (12, '软件测试', b'1', '2019-03-31 13:39:43', 5, 2);
|
||||
INSERT INTO `job` VALUES (19, '董事长', b'1', '2019-03-31 14:58:15', 1, 1);
|
||||
INSERT INTO `job` VALUES (20, 'test', b'1', '2019-06-25 08:50:52', 999, 1);
|
||||
INSERT INTO `job` VALUES (21, 'testtest', b'1', '2019-06-25 08:50:57', 999, 1);
|
||||
INSERT INTO `job` VALUES (22, 'testtesttest', b'1', '2019-06-25 08:51:01', 999, 1);
|
||||
INSERT INTO `job` VALUES (23, 'testtesttesttest', b'1', '2019-06-25 08:51:06', 999, 1);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for local_storage
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `local_storage`;
|
||||
CREATE TABLE `local_storage` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`real_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文件名',
|
||||
`suffix` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '后缀',
|
||||
`path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '路径',
|
||||
`type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '类型',
|
||||
`size` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '大小',
|
||||
`operate` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作人',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建日期',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '修改日期',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 20 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for log
|
||||
|
@ -193,7 +209,7 @@ CREATE TABLE `log` (
|
|||
`username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 12921 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 13914 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for menu
|
||||
|
@ -212,8 +228,9 @@ CREATE TABLE `menu` (
|
|||
`cache` bit(1) NULL DEFAULT b'0',
|
||||
`hidden` bit(1) NULL DEFAULT b'0',
|
||||
`component_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '-',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 41 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `FKqcf9gem97gqa5qjm4d3elcqt5`(`pid`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 40 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of menu
|
||||
|
@ -233,7 +250,7 @@ INSERT INTO `menu` VALUES (14, '2018-12-27 10:13:09', b'0', '邮件工具', 'too
|
|||
INSERT INTO `menu` VALUES (15, '2018-12-27 11:58:25', b'0', '富文本', 'components/Editor', 10, 52, 'fwb', 'tinymce', b'0', b'0', 'Editor');
|
||||
INSERT INTO `menu` VALUES (16, '2018-12-28 09:36:53', b'0', '图床管理', 'tools/picture/index', 36, 25, 'image', 'pictures', b'0', b'0', 'Pictures');
|
||||
INSERT INTO `menu` VALUES (17, '2018-12-28 15:09:49', b'1', '项目地址', '', 0, 0, 'github', 'https://github.com/elunez/eladmin', b'0', b'0', NULL);
|
||||
INSERT INTO `menu` VALUES (18, '2018-12-31 11:12:15', b'0', '七牛云存储', 'tools/qiniu/index', 36, 26, 'qiniu', 'qiniu', b'0', b'0', 'Qiniu');
|
||||
INSERT INTO `menu` VALUES (18, '2018-12-31 11:12:15', b'0', '存储管理', 'tools/storage/index', 36, 23, 'qiniu', 'storage', b'0', b'0', 'Storage');
|
||||
INSERT INTO `menu` VALUES (19, '2018-12-31 14:52:38', b'0', '支付宝工具', 'tools/aliPay/index', 36, 27, 'alipay', 'aliPay', b'0', b'0', 'AliPay');
|
||||
INSERT INTO `menu` VALUES (21, '2019-01-04 16:22:03', b'0', '多级菜单', '', 0, 900, 'menu', 'nested', b'0', b'0', NULL);
|
||||
INSERT INTO `menu` VALUES (22, '2019-01-04 16:23:29', b'0', '二级菜单1', 'nested/menu1/index', 21, 999, 'menu', 'menu1', b'0', b'0', NULL);
|
||||
|
@ -248,7 +265,7 @@ INSERT INTO `menu` VALUES (34, '2019-03-08 15:49:40', b'0', 'Yaml编辑器', 'co
|
|||
INSERT INTO `menu` VALUES (35, '2019-03-25 09:46:00', b'0', '部门管理', 'system/dept/index', 1, 6, 'dept', 'dept', b'0', b'0', 'Dept');
|
||||
INSERT INTO `menu` VALUES (36, '2019-03-29 10:57:35', b'0', '系统工具', '', 0, 20, 'sys-tools', 'sys-tools', b'0', b'0', NULL);
|
||||
INSERT INTO `menu` VALUES (37, '2019-03-29 13:51:18', b'0', '岗位管理', 'system/job/index', 1, 7, 'Steve-Jobs', 'job', b'0', b'0', 'Job');
|
||||
INSERT INTO `menu` VALUES (38, '2019-03-29 19:57:53', b'0', '接口文档', 'tools/swagger/index', 36, 23, 'swagger', 'swagger2', b'0', b'0', 'Swagger');
|
||||
INSERT INTO `menu` VALUES (38, '2019-03-29 19:57:53', b'0', '接口文档', 'tools/swagger/index', 36, 26, 'swagger', 'swagger2', b'0', b'0', 'Swagger');
|
||||
INSERT INTO `menu` VALUES (39, '2019-04-10 11:49:04', b'0', '字典管理', 'system/dict/index', 1, 8, 'dictionary', 'dict', b'0', b'0', 'Dict');
|
||||
|
||||
-- ----------------------------
|
||||
|
@ -361,7 +378,7 @@ CREATE TABLE `qiniu_content` (
|
|||
`update_time` datetime NULL DEFAULT NULL COMMENT '上传或同步的时间',
|
||||
`url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文件url',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 49 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 20 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for quartz_job
|
||||
|
@ -403,7 +420,7 @@ CREATE TABLE `quartz_log` (
|
|||
`params` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`time` bigint(20) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 29 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for role
|
||||
|
@ -446,6 +463,7 @@ INSERT INTO `roles_depts` VALUES (2, 5);
|
|||
INSERT INTO `roles_depts` VALUES (4, 6);
|
||||
INSERT INTO `roles_depts` VALUES (4, 7);
|
||||
INSERT INTO `roles_depts` VALUES (2, 8);
|
||||
INSERT INTO `roles_depts` VALUES (2, 9);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for roles_menus
|
||||
|
@ -456,8 +474,8 @@ CREATE TABLE `roles_menus` (
|
|||
`role_id` bigint(20) NOT NULL COMMENT '角色ID',
|
||||
PRIMARY KEY (`menu_id`, `role_id`) USING BTREE,
|
||||
INDEX `FKcngg2qadojhi3a651a5adkvbq`(`role_id`) USING BTREE,
|
||||
CONSTRAINT `FKcngg2qadojhi3a651a5adkvbq` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `FKq1knxf8ykt26we8k331naabjx` FOREIGN KEY (`menu_id`) REFERENCES `menu` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
CONSTRAINT `FKo7wsmlrrxb2osfaoavp46rv2r` FOREIGN KEY (`menu_id`) REFERENCES `menu` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `FKtag324maketmxffly3pdyh193` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
|
@ -568,7 +586,7 @@ INSERT INTO `roles_permissions` VALUES (2, 51);
|
|||
DROP TABLE IF EXISTS `user`;
|
||||
CREATE TABLE `user` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '头像地址',
|
||||
`avatar_id` bigint(20) NULL DEFAULT NULL COMMENT '头像',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建日期',
|
||||
`email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '邮箱',
|
||||
`enabled` bigint(20) NULL DEFAULT NULL COMMENT '状态:1启用、0禁用',
|
||||
|
@ -583,16 +601,30 @@ CREATE TABLE `user` (
|
|||
UNIQUE INDEX `username`(`username`) USING BTREE,
|
||||
INDEX `FK5rwmryny6jthaaxkogownknqp`(`dept_id`) USING BTREE,
|
||||
INDEX `FKfftoc2abhot8f2wu6cl9a5iky`(`job_id`) USING BTREE,
|
||||
INDEX `FKpq2dhypk2qgt68nauh2by22jb`(`avatar_id`) USING BTREE,
|
||||
CONSTRAINT `FK5rwmryny6jthaaxkogownknqp` FOREIGN KEY (`dept_id`) REFERENCES `dept` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `FKfftoc2abhot8f2wu6cl9a5iky` FOREIGN KEY (`job_id`) REFERENCES `job` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
CONSTRAINT `FKfftoc2abhot8f2wu6cl9a5iky` FOREIGN KEY (`job_id`) REFERENCES `job` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `FKpq2dhypk2qgt68nauh2by22jb` FOREIGN KEY (`avatar_id`) REFERENCES `user_avatar` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of user
|
||||
-- ----------------------------
|
||||
INSERT INTO `user` VALUES (1, 'https://i.loli.net/2019/04/04/5ca5b971e1548.jpeg', '2018-08-23 09:11:56', 'admin@eladmin.net', 1, 'e10adc3949ba59abbe56e057f20f883e', 'admin', '2019-05-18 17:34:21', 2, '18888888888', 11);
|
||||
INSERT INTO `user` VALUES (3, 'https://aurora-1255840532.cos.ap-chengdu.myqcloud.com/8918a306ea314404835a9196585c4b75.jpeg', '2018-12-27 20:05:26', 'test@eladmin.net', 1, 'e10adc3949ba59abbe56e057f20f883e', 'test', '2019-04-01 09:15:24', 2, '17777777777', 12);
|
||||
INSERT INTO `user` VALUES (5, 'https://aurora-1255840532.cos.ap-chengdu.myqcloud.com/8918a306ea314404835a9196585c4b75.jpeg', '2019-04-02 10:07:12', 'hr@eladmin.net', 1, 'e10adc3949ba59abbe56e057f20f883e', 'hr', NULL, 11, '15555555555', 8);
|
||||
INSERT INTO `user` VALUES (1, NULL, '2018-08-23 09:11:56', 'admin@eladmin.net', 1, 'e10adc3949ba59abbe56e057f20f883e', 'admin', '2019-05-18 17:34:21', 2, '18888888888', 11);
|
||||
INSERT INTO `user` VALUES (3, NULL, '2018-12-27 20:05:26', 'test@eladmin.net', 1, 'e10adc3949ba59abbe56e057f20f883e', 'test', '2019-04-01 09:15:24', 2, '17777777777', 12);
|
||||
INSERT INTO `user` VALUES (5, NULL, '2019-04-02 10:07:12', 'hr@eladmin.net', 1, 'e10adc3949ba59abbe56e057f20f883e', 'hr', NULL, 11, '15555555555', 8);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for user_avatar
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `user_avatar`;
|
||||
CREATE TABLE `user_avatar` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`real_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`size` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for users_roles
|
||||
|
@ -603,8 +635,8 @@ CREATE TABLE `users_roles` (
|
|||
`role_id` bigint(20) NOT NULL COMMENT '角色ID',
|
||||
PRIMARY KEY (`user_id`, `role_id`) USING BTREE,
|
||||
INDEX `FKq4eq273l04bpu4efj0jd0jb98`(`role_id`) USING BTREE,
|
||||
CONSTRAINT `users_roles_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `users_roles_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
CONSTRAINT `FKgd3iendaoyh04b95ykqise6qh` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `FKt4v0rrweyk393bdgt107vdx0x` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
|
@ -627,7 +659,7 @@ CREATE TABLE `verification_code` (
|
|||
`value` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '接收邮箱或者手机号码',
|
||||
`scenes` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '业务名称:如重置邮箱、重置密码等',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for visits
|
||||
|
@ -642,6 +674,6 @@ CREATE TABLE `visits` (
|
|||
`week_day` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `UK_11aksgq87euk9bcyeesfs4vtp`(`date`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 81 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 89 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
|
Loading…
Reference in New Issue