"src/main/vscode:/vscode.git/clone" did not exist on "0dc93a93768ab2545e9f5bd724d69bb99cc4aa6c"
Commit 67f0e6b3 authored by ZhengJie's avatar ZhengJie
Browse files

[代码完善] 由于免费图床过于不稳定,影响体验,因此删除图床管理模块。 富文本,markdown 替换为使用本地存储上传图片。如想继续使用,可以直接在其官网管理数据 https://sm.ms/

parent 0e6105c6
......@@ -41,8 +41,6 @@ public class ElAdminConstant {
* 常用接口
*/
public static class Url {
// 免费图床
public static final String SM_MS_URL = "https://sm.ms/api";
// IP归属地查询
public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp?ip=%s&json=true";
}
......
......@@ -43,7 +43,9 @@ import java.util.Map;
* @date 2018-12-27
*/
public class FileUtil extends cn.hutool.core.io.FileUtil {
private static final Logger log = LoggerFactory.getLogger(FileUtil.class);
/**
* 系统临时目录
* <br>
......@@ -75,6 +77,13 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
*/
private static final DecimalFormat DF = new DecimalFormat("0.00");
public static final String IMAGE = "图片";
public static final String TXT = "文档";
public static final String MUSIC = "音乐";
public static final String VIDEO = "视频";
public static final String OTHER = "其他";
/**
* MultipartFile转File
*/
......@@ -217,15 +226,15 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
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.contains(type)) {
return "图片";
return IMAGE;
} else if (documents.contains(type)) {
return "文档";
return TXT;
} else if (music.contains(type)) {
return "音乐";
return MUSIC;
} else if (video.contains(type)) {
return "视频";
return VIDEO;
} else {
return "其他";
return OTHER;
}
}
......
......@@ -53,7 +53,3 @@ code:
#密码加密传输,前端公钥加密,后端私钥解密
rsa:
private_key: MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A==
# sm.ms 图床的 token
smms:
token: 1oOP3ykFDI0K6ifmtvU7c8Y1eTWZSlyl
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* sm.ms图床
*
* @author Zheng Jie
* @date 2018-12-27
*/
@Data
@Entity
@Table(name = "tool_picture")
public class Picture implements Serializable {
@Id
@Column(name = "picture_id")
@ApiModelProperty(value = "ID", hidden = true)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ApiModelProperty(value = "文件名")
private String filename;
@ApiModelProperty(value = "图片url")
private String url;
@ApiModelProperty(value = "图片大小")
private String size;
@ApiModelProperty(value = "图片高")
private String height;
@ApiModelProperty(value = "图片宽")
private String width;
@Column(name = "delete_url")
@ApiModelProperty(value = "用于删除的url")
private String delete;
@ApiModelProperty(value = "创建者")
private String username;
@CreationTimestamp
@ApiModelProperty(value = "创建时间")
private Timestamp createTime;
/** 用于检测文件是否重复 */
private String md5Code;
@Override
public String toString() {
return "Picture{" +
"filename='" + filename + '\'' +
'}';
}
}
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.repository;
import me.zhengjie.domain.Picture;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author Zheng Jie
* @date 2018-12-27
*/
public interface PictureRepository extends JpaRepository<Picture,Long>, JpaSpecificationExecutor<Picture> {
/**
* 根据 Mds 值查询文件
* @param code 值
* @return /
*/
Picture findByMd5Code(String code);
/**
* 根据连接地址查询
* @param url /
* @return /
*/
boolean existsByUrl(String url);
}
......@@ -18,8 +18,11 @@ package me.zhengjie.rest;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.Log;
import me.zhengjie.domain.LocalStorage;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.service.LocalStorageService;
import me.zhengjie.service.dto.LocalStorageQueryCriteria;
import me.zhengjie.utils.FileUtil;
import me.zhengjie.utils.SecurityUtils;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
......@@ -67,6 +70,19 @@ public class LocalStorageController {
return new ResponseEntity<>(HttpStatus.CREATED);
}
@Log("上传图片")
@PostMapping("/pictures")
@ApiOperation("上传图片")
public ResponseEntity<Object> upload(@RequestParam MultipartFile file){
// 判断文件是否为图片
String suffix = FileUtil.getExtensionName(file.getOriginalFilename());
if(!FileUtil.IMAGE.equals(FileUtil.getFileType(suffix))){
throw new BadRequestException("只能上传图片");
}
LocalStorage localStorage = localStorageService.create(null, file);
return new ResponseEntity<>(localStorage, HttpStatus.OK);
}
@ApiOperation("修改文件")
@PutMapping
@PreAuthorize("@el.check('storage:edit')")
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.Log;
import me.zhengjie.domain.Picture;
import me.zhengjie.service.PictureService;
import me.zhengjie.service.dto.PictureQueryCriteria;
import me.zhengjie.utils.SecurityUtils;
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.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author 郑杰
* @date 2018/09/20 14:13:32
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/pictures")
@Api(tags = "工具:免费图床管理")
public class PictureController {
private final PictureService pictureService;
@Log("查询图片")
@PreAuthorize("@el.check('pictures:list')")
@GetMapping
@ApiOperation("查询图片")
public ResponseEntity<Object> query(PictureQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(pictureService.queryAll(criteria,pageable),HttpStatus.OK);
}
@Log("导出数据")
@ApiOperation("导出数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('pictures:list')")
public void download(HttpServletResponse response, PictureQueryCriteria criteria) throws IOException {
pictureService.download(pictureService.queryAll(criteria), response);
}
@Log("上传图片")
@PreAuthorize("@el.check('pictures:add')")
@PostMapping
@ApiOperation("上传图片")
public ResponseEntity<Object> upload(@RequestParam MultipartFile file){
String userName = SecurityUtils.getCurrentUsername();
Picture picture = pictureService.upload(file,userName);
return new ResponseEntity<>(picture,HttpStatus.OK);
}
@Log("同步图床数据")
@ApiOperation("同步图床数据")
@PostMapping(value = "/synchronize")
public ResponseEntity<Object> synchronize(){
pictureService.synchronize();
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("多选删除图片")
@ApiOperation("多选删除图片")
@PreAuthorize("@el.check('pictures:del')")
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
pictureService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}
......@@ -56,8 +56,9 @@ public interface LocalStorageService {
* 上传
* @param name 文件名称
* @param file 文件
* @return
*/
void create(String name, MultipartFile file);
LocalStorage create(String name, MultipartFile file);
/**
* 编辑
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.service;
import me.zhengjie.domain.Picture;
import me.zhengjie.service.dto.PictureQueryCriteria;
import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* @author Zheng Jie
* @date 2018-12-27
*/
public interface PictureService {
/**
* 分页查询
* @param criteria 条件
* @param pageable 分页参数
* @return /
*/
Object queryAll(PictureQueryCriteria criteria, Pageable pageable);
/**
* 查询全部数据
* @param criteria 条件
* @return /
*/
List<Picture> queryAll(PictureQueryCriteria criteria);
/**
* 上传文件
* @param file /
* @param username /
* @return /
*/
Picture upload(MultipartFile file, String username);
/**
* 根据ID查询
* @param id /
* @return /
*/
Picture findById(Long id);
/**
* 多选删除
* @param ids /
*/
void deleteAll(Long[] ids);
/**
* 导出
* @param queryAll 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<Picture> queryAll, HttpServletResponse response) throws IOException;
/**
* 同步数据
*/
void synchronize();
}
......@@ -71,7 +71,7 @@ public class LocalStorageServiceImpl implements LocalStorageService {
@Override
@Transactional(rollbackFor = Exception.class)
public void create(String name, MultipartFile multipartFile) {
public LocalStorage create(String name, MultipartFile multipartFile) {
FileUtil.checkSize(properties.getMaxSize(), multipartFile.getSize());
String suffix = FileUtil.getExtensionName(multipartFile.getOriginalFilename());
String type = FileUtil.getFileType(suffix);
......@@ -89,7 +89,7 @@ public class LocalStorageServiceImpl implements LocalStorageService {
type,
FileUtil.getSize(multipartFile.getSize())
);
localStorageRepository.save(localStorage);
return localStorageRepository.save(localStorage);
}catch (Exception e){
FileUtil.del(file);
throw e;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.service.impl;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.domain.Picture;
import me.zhengjie.repository.PictureRepository;
import me.zhengjie.service.PictureService;
import me.zhengjie.service.dto.PictureQueryCriteria;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.utils.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.*;
/**
* @author Zheng Jie
* @date 2018-12-27
*/
@Slf4j
@RequiredArgsConstructor
@Service(value = "pictureService")
public class PictureServiceImpl implements PictureService {
@Value("${smms.token}")
private String token;
private final PictureRepository pictureRepository;
private static final String SUCCESS = "success";
private static final String CODE = "code";
private static final String MSG = "message";
@Override
public Object queryAll(PictureQueryCriteria criteria, Pageable pageable){
return PageUtil.toPage(pictureRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
}
@Override
public List<Picture> queryAll(PictureQueryCriteria criteria) {
return pictureRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder));
}
@Override
@Transactional(rollbackFor = Throwable.class)
public Picture upload(MultipartFile multipartFile, String username) {
File file = FileUtil.toFile(multipartFile);
// 验证是否重复上传
Picture picture = pictureRepository.findByMd5Code(FileUtil.getMd5(file));
if(picture != null){
return picture;
}
HashMap<String, Object> paramMap = new HashMap<>(1);
paramMap.put("smfile", file);
// 上传文件
String result= HttpRequest.post(ElAdminConstant.Url.SM_MS_URL + "/v2/upload")
.header("Authorization", token)
.form(paramMap)
.timeout(20000)
.execute().body();
JSONObject jsonObject = JSONUtil.parseObj(result);
if(!jsonObject.get(CODE).toString().equals(SUCCESS)){
throw new BadRequestException(TranslatorUtil.translate(jsonObject.get(MSG).toString()));
}
picture = JSON.parseObject(jsonObject.get("data").toString(), Picture.class);
picture.setSize(FileUtil.getSize(Integer.parseInt(picture.getSize())));
picture.setUsername(username);
picture.setMd5Code(FileUtil.getMd5(file));
picture.setFilename(FileUtil.getFileNameNoEx(multipartFile.getOriginalFilename())+"."+FileUtil.getExtensionName(multipartFile.getOriginalFilename()));
pictureRepository.save(picture);
//删除临时文件
FileUtil.del(file);
return picture;
}
@Override
public Picture findById(Long id) {
Picture picture = pictureRepository.findById(id).orElseGet(Picture::new);
ValidationUtil.isNull(picture.getId(),"Picture","id",id);
return picture;
}
@Override
public void deleteAll(Long[] ids) {
for (Long id : ids) {
Picture picture = findById(id);
try {
HttpUtil.get(picture.getDelete());
pictureRepository.delete(picture);
} catch(Exception e){
pictureRepository.delete(picture);
}
}
}
@Override
public void synchronize() {
//链式构建请求
String result = HttpRequest.get(ElAdminConstant.Url.SM_MS_URL + "/v2/upload_history")
//头信息,多个头信息多次调用此方法即可
.header("Authorization", token)
.timeout(20000)
.execute().body();
JSONObject jsonObject = JSONUtil.parseObj(result);
List<Picture> pictures = JSON.parseArray(jsonObject.get("data").toString(), Picture.class);
for (Picture picture : pictures) {
if(!pictureRepository.existsByUrl(picture.getUrl())){
picture.setSize(FileUtil.getSize(Integer.parseInt(picture.getSize())));
picture.setUsername("System Sync");
picture.setMd5Code(null);
pictureRepository.save(picture);
}
}
}
@Override
public void download(List<Picture> queryAll, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (Picture picture : queryAll) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("文件名", picture.getFilename());
map.put("图片地址", picture.getUrl());
map.put("文件大小", picture.getSize());
map.put("操作人", picture.getUsername());
map.put("高度", picture.getHeight());
map.put("宽度", picture.getWidth());
map.put("删除地址", picture.getDelete());
map.put("创建日期", picture.getCreateTime());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}
-- code_gen_config 表改动 start --
alter table code_gen_config CHANGE id config_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
-- code_gen_config end --
-- code_column_config 表改动 start --
alter table code_column_config CHANGE id column_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
-- code_column_config end --
\ No newline at end of file
This diff is collapsed.
-- mnt_app 表改动 start --
alter table mnt_app CHANGE id app_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
/* 加入通用字段 */
alter table mnt_app add create_by VARCHAR(255) COMMENT '创建者';
alter table mnt_app add update_by VARCHAR(255) COMMENT '更新者';
alter table mnt_app add update_time datetime COMMENT '更新时间';
-- mnt_app end --
-- mnt_database 表改动 start --
alter table mnt_database CHANGE id db_id VARCHAR(50) COMMENT 'ID';
/* 加入通用字段 */
alter table mnt_database add create_by VARCHAR(255) COMMENT '创建者';
alter table mnt_database add update_by VARCHAR(255) COMMENT '更新者';
alter table mnt_database add update_time datetime COMMENT '更新时间';
-- mnt_database end --
-- mnt_deploy 表改动 start --
alter table mnt_deploy CHANGE id deploy_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
/* 加入通用字段 */
alter table mnt_deploy add create_by VARCHAR(255) COMMENT '创建者';
alter table mnt_deploy add update_by VARCHAR(255) COMMENT '更新者';
alter table mnt_deploy add update_time datetime COMMENT '更新时间';
-- mnt_deploy end --
-- mnt_server 表改动 start --
alter table mnt_server CHANGE id server_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
/* 加入通用字段 */
alter table mnt_server add create_by VARCHAR(255) COMMENT '创建者';
alter table mnt_server add update_by VARCHAR(255) COMMENT '更新者';
alter table mnt_server add update_time datetime COMMENT '更新时间';
-- mnt_server end --
-- mnt_deploy_history 表改动 start --
alter table mnt_deploy_history CHANGE id history_id VARCHAR(50) COMMENT 'ID';
-- mnt_deploy end --
-- sys_user 表变动 start --
/* id 改为 user_id */
alter table sys_user CHANGE id user_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
/* 实际操作中需要将 avatar 表的数据移入 sys_user 中 */
alter table sys_user CHANGE avatar_id avatar_url VARCHAR(255) COMMENT '头像地址';
/* 添加头像路径 */
alter table sys_user add avatar_path VARCHAR(255) COMMENT '头像真实路径' AFTER avatar_url;
/* 判断是否为 admin */
alter table sys_user add is_admin bit(1) COMMENT '是否为admin账号' DEFAULT 0 AFTER create_time;
/* sex 改为 gender */
alter table sys_user CHANGE sex gender VARCHAR(2) COMMENT '性别';
/* last_password_reset_time 改为 pwd_reset_time */
alter table sys_user CHANGE last_password_reset_time pwd_reset_time datetime COMMENT '修改密码的时间';
/* 加入通用字段 */
alter table sys_user add update_by VARCHAR(255) COMMENT '更新者' AFTER enabled;
alter table sys_user add create_by VARCHAR(255) COMMENT '创建者' AFTER enabled;
alter table sys_user add update_time datetime COMMENT '更新时间';
-- sys_user end --
-- sys_role 表变动 start--
/* id 改为 role_id */
alter table sys_role CHANGE id role_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
/* remark 改为 description */
alter table sys_role CHANGE remark description VARCHAR(255) COMMENT '描述';
/* 删除权限字段 */
ALTER TABLE sys_role DROP permission;
/* 加入通用字段 */
alter table sys_role add update_by VARCHAR(255) COMMENT '更新者';
alter table sys_role add create_by VARCHAR(255) COMMENT '创建者';
alter table sys_role add update_time datetime COMMENT '更新时间';
-- sys_role end --
-- sys_menu 表变动 start--
/* id 改为 menu_id */
alter table sys_menu CHANGE id menu_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
/* name 改为 title */
alter table sys_menu CHANGE name title VARCHAR(255) COMMENT '菜单标题';
/* component_name 改为 name */
alter table sys_menu CHANGE component_name name VARCHAR(255) COMMENT '组件名称';
/* sort 改为 menu_sort */
alter table sys_menu CHANGE sort menu_sort INT(5) COMMENT '排序';
/* pid 允许为空 */
alter table sys_menu modify pid BIGINT(20) null;
/* 加入子节点数量字段 */
alter table sys_menu add sub_count INT(5) DEFAULT 0 COMMENT '子菜单数目';
/* 加入通用字段 */
alter table sys_menu add update_by VARCHAR(255) COMMENT '更新者';
alter table sys_menu add create_by VARCHAR(255) COMMENT '创建者';
alter table sys_menu add update_time datetime COMMENT '更新时间';
-- sys_menu end --
-- sys_job 表改动 start --
/* id 改为 menu_id */
alter table sys_job CHANGE id job_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
/* sort 改为 job_sort */
alter table sys_job CHANGE sort job_sort INT(5) COMMENT '排序';
/* 删除岗位与部门的关系 */
ALTER TABLE sys_job DROP dept_id;
/* 加入通用字段 */
alter table sys_job add create_by VARCHAR(255) COMMENT '创建者';
alter table sys_job add update_by VARCHAR(255) COMMENT '更新者';
alter table sys_job add update_time datetime COMMENT '更新时间';
-- sys_job end --
-- sys_dept 表改动 start--
/* id 改为 menu_id */
alter table sys_dept CHANGE id dept_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
/* pid 允许为空 */
alter table sys_dept modify pid BIGINT(20) null;
/* 加入排序字段 */
alter table sys_dept add dept_sort int(5) DEFAULT 999 COMMENT '排序';
/* 加入子节点数量字段 */
alter table sys_dept add sub_count INT(5) DEFAULT 0 COMMENT '子部门数目';
/* 加入通用字段 */
alter table sys_dept add create_by VARCHAR(255) COMMENT '创建者';
alter table sys_dept add update_by VARCHAR(255) COMMENT '更新者';
alter table sys_dept add update_time datetime COMMENT '更新时间';
-- sys_dept end --
-- sys_dict 表改动 start --
/* id 改为 menu_id */
alter table sys_dict CHANGE id dict_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
/* remark 改为 description */
alter table sys_dict CHANGE remark description VARCHAR(255) COMMENT '描述';
/* 加入通用字段 */
alter table sys_dict add create_by VARCHAR(255) COMMENT '创建者';
alter table sys_dict add update_by VARCHAR(255) COMMENT '更新者';
alter table sys_dict add update_time datetime COMMENT '更新时间';
-- sys_dict end --
-- sys_dict_detail 表改动 start --
/* id 改为 menu_id */
alter table sys_dict_detail CHANGE id detail_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
/* sort 改为 dict_sort */
alter table sys_dict_detail CHANGE sort dict_sort INT(5) COMMENT '排序';
/* 加入通用字段 */
alter table sys_dict_detail add create_by VARCHAR(255) COMMENT '创建者';
alter table sys_dict_detail add update_by VARCHAR(255) COMMENT '更新者';
alter table sys_dict_detail add update_time datetime COMMENT '更新时间';
-- sys_dict_detail end --
-- sys_quartz_job and sys_quartz_log 表改动 start --
/* id 改为 job_id */
alter table sys_quartz_job CHANGE id job_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
alter table sys_quartz_log CHANGE id log_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
/* baen_name 改为 bean_name */
alter table sys_quartz_log CHANGE baen_name bean_name VARCHAR(255) COMMENT 'Bean 名称';
/* remark 改为 description */
alter table sys_quartz_job CHANGE remark description VARCHAR(255) COMMENT '备注';
/* 加入通用字段 */
alter table sys_quartz_job add create_by VARCHAR(255) COMMENT '创建者';
alter table sys_quartz_job add update_by VARCHAR(255) COMMENT '更新者';
alter table sys_quartz_job add update_time datetime COMMENT '更新时间';
/* 添加负责人 与 报警邮箱 */
alter table sys_quartz_job add person_in_charge VARCHAR(100) COMMENT '负责人';
alter table sys_quartz_job add email VARCHAR(100) COMMENT '报警邮箱';
alter table sys_quartz_job add sub_task VARCHAR(100) COMMENT '子任务ID';
alter table sys_quartz_job add pause_after_failure bit(1) COMMENT '任务失败后是否暂停';
-- sys_quartz_job end --
-- sys_monitor_server 表改动 start --
alter table sys_monitor_server CHANGE id monitor_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
/* sort 改为 monitor_sort */
alter table sys_monitor_server CHANGE sort monitor_sort INT(5) COMMENT '排序';
/* 加入通用字段 */
alter table sys_monitor_server add create_by VARCHAR(255) COMMENT '创建者';
alter table sys_monitor_server add update_by VARCHAR(255) COMMENT '更新者';
alter table sys_monitor_server add create_time datetime COMMENT '创建时间';
alter table sys_monitor_server add update_time datetime COMMENT '更新时间';
-- sys_monitor_server end --
-- sys_log 表改动 start --
alter table sys_log CHANGE id log_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
-- sys_log end --
\ No newline at end of file
-- tool_alipay_config 表改动 start --
alter table tool_alipay_config CHANGE id config_id BIGINT(20) COMMENT 'ID';
-- tool_alipay_config end --
-- tool_email_config 表改动 start --
alter table tool_email_config CHANGE id config_id BIGINT(20) COMMENT 'ID';
-- tool_email_config end --
-- tool_local_storage 表改动 start --
alter table tool_local_storage CHANGE id storage_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
/* 加入通用字段 */
alter table tool_local_storage add create_by VARCHAR(255) COMMENT '创建者';
alter table tool_local_storage add update_by VARCHAR(255) COMMENT '更新者';
alter table tool_local_storage add update_time datetime COMMENT '更新时间';
/* 删除 operate 字段 */
ALTER TABLE tool_local_storage DROP operate;
-- tool_local_storage end --
-- tool_picture 表改动 start --
alter table tool_picture CHANGE id picture_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
-- tool_picture end --
-- tool_qiniu_config 表改动 start --
alter table tool_qiniu_config CHANGE id config_id BIGINT(20) COMMENT 'ID';
-- tool_qiniu_config end --
-- tool_qiniu_content 表改动 start --
alter table tool_qiniu_content CHANGE id content_id BIGINT(20) AUTO_INCREMENT COMMENT 'ID';
-- tool_qiniu_content end --
-- 删除免费图床表
DROP TABLE tool_picture;
\ No newline at end of file
/* 检索并拼接sql语句,复制所有结果删除所有外键 */
SELECT CONCAT('ALTER TABLE ',TABLE_SCHEMA,'.',TABLE_NAME,' DROP FOREIGN KEY ',CONSTRAINT_NAME,';')
FROM information_schema.TABLE_CONSTRAINTS c
WHERE c.TABLE_SCHEMA='eladmin' AND c.CONSTRAINT_TYPE='FOREIGN KEY';
-- 删除头像关联表,将头像信息存入 sys_user 表,执行前先执行 字段调整. --
DROP TABLE user_avatar
\ No newline at end of file
-- ----------------------------
-- Table structure for sys_users_jobs
-- ----------------------------
DROP TABLE IF EXISTS `sys_users_jobs`;
CREATE TABLE `sys_users_jobs` (
`user_id` bigint(20) NOT NULL COMMENT '用户ID',
`job_id` bigint(20) NOT NULL COMMENT '岗位ID',
PRIMARY KEY (`user_id`,`job_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- sys_user 需要将岗位信息移入 sys_users_jobs 表中,这里不提供移入脚本--
ALTER TABLE sys_user DROP job_id;
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment