优化
This commit is contained in:
parent
fbb91ceed1
commit
09ce8d46a9
@ -14,8 +14,8 @@ public class CorsConfig{
|
||||
public FilterRegistrationBean corsFilter() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.setAllowCredentials(true);
|
||||
// config.addAllowedOrigin("*");
|
||||
config.addAllowedOrigin("http://10.75.253.12:6090");
|
||||
config.addAllowedOrigin("*");
|
||||
// config.addAllowedOrigin("http://10.75.253.12:6090");
|
||||
config.addAllowedHeader("*");
|
||||
config.addAllowedMethod("*");
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.controller.admin;
|
||||
|
||||
import cn.xuyanwu.spring.file.storage.FileInfo;
|
||||
import cn.xuyanwu.spring.file.storage.FileStorageService;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.file.FileUtil;
|
||||
@ -16,6 +17,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -40,38 +42,23 @@ public class FileController {
|
||||
/**
|
||||
* 上传文件到指定存储平台,成功返回文件信息
|
||||
*/
|
||||
// @OperLog(operModul = "文件管理", operType = "文件上传", operDesc = "文件上传")
|
||||
// @ApiOperation(value = "文件上传", notes = "文件上传", httpMethod="POST")
|
||||
// @PostMapping("/upload")
|
||||
// public Result<FileInfo> uploadPlatform(MultipartFile file) {
|
||||
// return Result.success(fileStorageService.of(file)
|
||||
// .setPlatform("minio-1") //使用指定的存储平台
|
||||
// .upload());
|
||||
// }
|
||||
|
||||
/**
|
||||
* 上传文件到本地,成功返回文件信息
|
||||
*/
|
||||
@OperLog(operModul = "文件管理", operType = "文件上传", operDesc = "文件上传")
|
||||
@ApiOperation(value = "文件上传", notes = "文件上传", httpMethod="POST")
|
||||
@PostMapping("/upload")
|
||||
public Result<Map<String, Object>> upload(MultipartFile file) {
|
||||
return Result.success(fileDetailService.upload(file));
|
||||
public Result<FileInfo> uploadPlatform(MultipartFile file) {
|
||||
return Result.success(fileStorageService.of(file)
|
||||
.setPlatform("minio-1") //使用指定的存储平台
|
||||
.upload());
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 上传BASE64文件
|
||||
// * 上传文件到本地,成功返回文件信息
|
||||
// */
|
||||
// @OperLog(operModul = "文件管理", operType = "BASE64文件上传", operDesc = "BASE64文件上传")
|
||||
// @ApiOperation(value = "BASE64文件上传", notes = "BASE64文件上传", httpMethod="POST")
|
||||
// @ApiImplicitParam(name = "base64", value = "BASE64字符串", required = true, dataType = "String")
|
||||
// @PostMapping("/uploadBase64")
|
||||
// public Result<FileInfo> uploadBase64(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
// String base64 = MapUtils.getString(map, "base64");
|
||||
// MultipartFile multipartFile = FileUtil.base64toMultipart(base64, "text.jpg");
|
||||
// return Result.success(fileStorageService.of(multipartFile)
|
||||
// .setPlatform("minio-1") //使用指定的存储平台
|
||||
// .upload());
|
||||
// @OperLog(operModul = "文件管理", operType = "文件上传", operDesc = "文件上传")
|
||||
// @ApiOperation(value = "文件上传", notes = "文件上传", httpMethod="POST")
|
||||
// @PostMapping("/upload")
|
||||
// public Result<Map<String, Object>> upload(MultipartFile file) {
|
||||
// return Result.success(fileDetailService.upload(file));
|
||||
// }
|
||||
|
||||
/**
|
||||
@ -81,48 +68,46 @@ public class FileController {
|
||||
@ApiOperation(value = "BASE64文件上传", notes = "BASE64文件上传", httpMethod="POST")
|
||||
@ApiImplicitParam(name = "base64", value = "BASE64字符串", required = true, dataType = "String")
|
||||
@PostMapping("/uploadBase64")
|
||||
public Result<Map<String, Object>> uploadBase64(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
public Result<FileInfo> uploadBase64(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
String base64 = MapUtils.getString(map, "base64");
|
||||
MultipartFile multipartFile = FileUtil.base64toMultipart(base64, "text.jpg");
|
||||
return Result.success(fileDetailService.upload(multipartFile));
|
||||
return Result.success(fileStorageService.of(multipartFile)
|
||||
.setPlatform("minio-1") //使用指定的存储平台
|
||||
.upload());
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 上传BASE64文件
|
||||
// */
|
||||
// @OperLog(operModul = "文件管理", operType = "BASE64文件上传", operDesc = "BASE64文件上传")
|
||||
// @ApiOperation(value = "BASE64文件上传", notes = "BASE64文件上传", httpMethod="POST")
|
||||
// @ApiImplicitParam(name = "base64", value = "BASE64字符串", required = true, dataType = "String")
|
||||
// @PostMapping("/uploadBase64")
|
||||
// public Result<Map<String, Object>> uploadBase64(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
// String base64 = MapUtils.getString(map, "base64");
|
||||
// MultipartFile multipartFile = FileUtil.base64toMultipart(base64, "text.jpg");
|
||||
// return Result.success(fileDetailService.upload(multipartFile));
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*/
|
||||
// @OperLog(operModul = "文件管理", operType = "文件下载", operDesc = "文件下载")
|
||||
// @ApiOperation(value = "文件下载", notes = "文件下载", httpMethod="POST")
|
||||
// @ApiImplicitParam(name = "fileUrl", value = "文件路径", paramType = "body", dataType = "String")
|
||||
// @PostMapping("/download")
|
||||
// public void download(@ApiIgnore @RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception {
|
||||
// // 获取文件信息
|
||||
// String fileUrl = MapUtils.getString(map, "fileUrl");
|
||||
// FileInfo fileInfo = fileStorageService.getFileInfoByUrl(fileUrl);
|
||||
// if (null == fileInfo) {
|
||||
// throw new Exception("缩略图文件下载失败,文件不存在!fileInfo:" + fileInfo);
|
||||
// }
|
||||
// response.setHeader("Content-disposition", "attachment; filename=" + fileUrl.substring(fileUrl.lastIndexOf("/") + 1));
|
||||
// response.setContentType("application/octet-stream");// 定义输出类型
|
||||
// fileStorageService.download(fileInfo).outputStream(response.getOutputStream());
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取预览文件流
|
||||
*/
|
||||
// @OperLog(operModul = "文件管理", operType = "获取预览文件流", operDesc = "获取预览文件流")
|
||||
// @ApiOperation(value = "获取预览文件流", notes = "获取预览文件流", httpMethod="POST")
|
||||
// @GetMapping("/preview")
|
||||
// public void download(@RequestParam(value = "fileUrl", required = true) String fileUrl, HttpServletResponse response) throws Exception {
|
||||
// // 获取文件信息
|
||||
// FileInfo fileInfo = fileStorageService.getFileInfoByUrl(fileUrl);
|
||||
// if (null == fileInfo) {
|
||||
// throw new Exception("缩略图文件预览失败,文件不存在!fileInfo:" + fileInfo);
|
||||
// }
|
||||
// response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode(fileInfo.getOriginalFilename(), "UTF-8"));
|
||||
// response.setContentType("application/octet-stream");// 定义输出类型
|
||||
// fileStorageService.download(fileInfo).outputStream(response.getOutputStream());
|
||||
// }
|
||||
@OperLog(operModul = "文件管理", operType = "文件下载", operDesc = "文件下载")
|
||||
@ApiOperation(value = "文件下载", notes = "文件下载", httpMethod="POST")
|
||||
@ApiImplicitParam(name = "fileUrl", value = "文件路径", paramType = "body", dataType = "String")
|
||||
@PostMapping("/download")
|
||||
public void download(@ApiIgnore @RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception {
|
||||
// 获取文件信息
|
||||
String fileUrl = MapUtils.getString(map, "fileUrl");
|
||||
FileInfo fileInfo = fileStorageService.getFileInfoByUrl(fileUrl);
|
||||
if (null == fileInfo) {
|
||||
throw new Exception("缩略图文件下载失败,文件不存在!fileInfo:" + fileInfo);
|
||||
}
|
||||
response.setHeader("Content-disposition", "attachment; filename=" + fileUrl.substring(fileUrl.lastIndexOf("/") + 1));
|
||||
response.setContentType("application/octet-stream");// 定义输出类型
|
||||
fileStorageService.download(fileInfo).outputStream(response.getOutputStream());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预览文件流
|
||||
@ -132,6 +117,23 @@ public class FileController {
|
||||
@GetMapping("/preview")
|
||||
public void download(@RequestParam(value = "fileUrl", required = true) String fileUrl, HttpServletResponse response) throws Exception {
|
||||
// 获取文件信息
|
||||
fileDetailService.download(fileUrl, response);
|
||||
FileInfo fileInfo = fileStorageService.getFileInfoByUrl(fileUrl);
|
||||
if (null == fileInfo) {
|
||||
throw new Exception("缩略图文件预览失败,文件不存在!fileInfo:" + fileInfo);
|
||||
}
|
||||
response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode(fileInfo.getOriginalFilename(), "UTF-8"));
|
||||
response.setContentType("application/octet-stream");// 定义输出类型
|
||||
fileStorageService.download(fileInfo).outputStream(response.getOutputStream());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预览文件流
|
||||
*/
|
||||
// @OperLog(operModul = "文件管理", operType = "获取预览文件流", operDesc = "获取预览文件流")
|
||||
// @ApiOperation(value = "获取预览文件流", notes = "获取预览文件流", httpMethod="POST")
|
||||
// @GetMapping("/preview")
|
||||
// public void download(@RequestParam(value = "fileUrl", required = true) String fileUrl, HttpServletResponse response) throws Exception {
|
||||
// // 获取文件信息
|
||||
// fileDetailService.download(fileUrl, response);
|
||||
// }
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ public class SystemUserAuthController {
|
||||
if (!CommonUtil.checkStrongPwd(password)) {
|
||||
return Result.error("密码必须包含数字、大小写字母、特殊符号且大于8位");
|
||||
}
|
||||
boolean flag = systemUserService.updatePassword(user.getUserId(), Aes.encrypt(password));
|
||||
boolean flag = systemUserService.updatePassword(user.getUserId(), password);
|
||||
if (flag) {
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ public class SystemUserOpController {
|
||||
public Result<List<SystemRole>> roleList() {
|
||||
Government government = governmentService.list().get(0);
|
||||
List<SystemRole> list = systemRoleService.list(Wrappers.<SystemRole>lambdaQuery().eq(SystemRole::getSn, government.getGovernmentSn())
|
||||
.gt(SystemRole::getPriority, 3));
|
||||
.eq(SystemRole::getSysDefault, 0).gt(SystemRole::getPriority, 3));
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
|
||||
@ -90,4 +90,11 @@ public class SystemRole implements Serializable {
|
||||
@Excel(name = "优先级 越小越靠前(排序字段)", width = 15)
|
||||
@ApiModelProperty(value = "优先级 越小越靠前(排序字段)")
|
||||
private Integer priority;
|
||||
|
||||
/**
|
||||
* 系统预设
|
||||
*/
|
||||
@Excel(name = "系统预设", width = 15)
|
||||
@ApiModelProperty(value = "系统预设")
|
||||
private Integer sysDefault;
|
||||
}
|
||||
|
||||
@ -2,7 +2,8 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhgd.xmgl.modules.basicdata.mapper.SystemUserMapper">
|
||||
<sql id="userInfo">
|
||||
u.user_id, u.account, u.create_time, u.real_name, u.user_tel, u.department, u.state, u.password, u.email, u.sex, u.job_name, u.remark
|
||||
u.user_id, u.account, u.create_time, u.real_name, u.user_tel, u.department, u.state, u.password, u.show_password, u.email, u.sex, u.job_name, u.remark
|
||||
,u.account_type, u.sn
|
||||
</sql>
|
||||
|
||||
<select id="findByUsername" resultType="com.zhgd.xmgl.modules.basicdata.entity.SystemUser" parameterType="string">
|
||||
|
||||
@ -247,6 +247,10 @@ public class BaseMenuServiceImpl extends ServiceImpl<BaseMenuMapper, BaseMenu> i
|
||||
}
|
||||
baseMenuList.addAll(baseMenus);
|
||||
menuList.addAll(TreeUtil.formatMenu(baseMenuList));
|
||||
// 查询相对应的按钮权限
|
||||
List<BaseAction> baseAction = baseActionMapper.selectList(Wrappers.<BaseAction>lambdaQuery().in(BaseAction::getMenuId,
|
||||
baseMenus.stream().map(m -> m.getMenuId()).collect(Collectors.toList())).eq(BaseAction::getStatus, 1));
|
||||
menuList.addAll(TreeUtil.formatAction(baseAction));
|
||||
return TreeUtil.build(menuList, 0, moduleId, 1);
|
||||
}
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ public class SystemRoleServiceImpl extends ServiceImpl<SystemRoleMapper, SystemR
|
||||
queryWrapper.eq("create_by", user.getUserId());
|
||||
}
|
||||
}
|
||||
queryWrapper.lambda().eq(SystemRole::getSysDefault, 0);
|
||||
queryWrapper.orderByAsc("priority");
|
||||
Page<SystemRole> page = PageUtil.getPage(map);
|
||||
return baseMapper.selectPage(page, queryWrapper);
|
||||
@ -53,11 +54,11 @@ public class SystemRoleServiceImpl extends ServiceImpl<SystemRoleMapper, SystemR
|
||||
@Override
|
||||
public List<SystemRole> getList(SystemRole systemRole) {
|
||||
SecurityUser user = SecurityUtil.getUser();
|
||||
if (user.getAccountType() == 4) {
|
||||
systemRole.setSn(user.getSn());
|
||||
if (!user.isManager()) {
|
||||
systemRole.setCreateBy(user.getUserId());
|
||||
}
|
||||
QueryWrapper<SystemRole> queryWrapper = QueryGenerator.initQueryWrapper(systemRole);
|
||||
queryWrapper.lambda().eq(SystemRole::getSysDefault, 0);
|
||||
queryWrapper.orderByAsc("priority");
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@ -56,14 +56,12 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
Page<SystemUser> page = PageUtil.getPage(map);
|
||||
SecurityUser user = SecurityUtil.getUser();
|
||||
QueryWrapper<SystemUser> wrapper = QueryGenerator.initPageQueryWrapper(SystemUser.class, map);
|
||||
wrapper.eq("u.account_type", user.getAccountType());
|
||||
if (user.getAccountType() == 4) {
|
||||
wrapper.eq("u.sn", user.getSn());
|
||||
if (!user.isManager()) {
|
||||
wrapper.eq("u.create_by", user.getUserId());
|
||||
}
|
||||
}
|
||||
// wrapper.eq("u.is_manager", 0);
|
||||
String deptId = MapUtils.getString(map, "deptId");
|
||||
if (StringUtils.isNotBlank(deptId)) {
|
||||
String deptIds = systemDeptMapper.getChildrenByDeptId(deptId);
|
||||
@ -76,8 +74,9 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
public List<SystemUserDto> getPageList(SystemUser systemUser) {
|
||||
QueryWrapper<SystemUser> wrapper = Wrappers.<SystemUser>query();
|
||||
SecurityUser user = SecurityUtil.getUser();
|
||||
wrapper.eq("u.account_type", user.getAccountType());
|
||||
wrapper.eq("u.sn", systemUser.getSn() == null ? user.getSn() : systemUser.getSn());
|
||||
if (user.getAccountType() == 4) {
|
||||
wrapper.eq("u.sn", systemUser.getSn());
|
||||
}
|
||||
wrapper.ne("u.user_id", user.getUserId());
|
||||
return baseMapper.getPageList(wrapper);
|
||||
}
|
||||
@ -92,10 +91,10 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
SystemUser systemUser = new SystemUser();
|
||||
BeanUtils.copyProperties(systemUserVo, systemUser);
|
||||
systemUser.setCreateTime(new Date());
|
||||
systemUser.setSn(user.getSn());
|
||||
systemUser.setSn(systemUserVo.getSn() == null ? user.getSn() : systemUserVo.getSn());
|
||||
systemUser.setShowPassword(systemUser.getPassword());
|
||||
systemUser.setIsManager(false);
|
||||
systemUser.setAccountType(user.getAccountType());
|
||||
systemUser.setAccountType(systemUserVo.getAccountType() == null ? user.getAccountType() : systemUserVo.getAccountType());
|
||||
systemUser.setCreateBy(user.getUserId());
|
||||
this.save(systemUser);
|
||||
//新增用户角色
|
||||
@ -114,6 +113,7 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
}
|
||||
SystemUser systemUser = new SystemUser();
|
||||
BeanUtils.copyProperties(systemUserVo, systemUser);
|
||||
systemUser.setShowPassword(systemUser.getPassword());
|
||||
this.updateById(systemUser);
|
||||
//新增用户角色
|
||||
systemUserRoleMapper.delete(Wrappers.<SystemUserRole>lambdaQuery()
|
||||
|
||||
@ -3,13 +3,13 @@ http.port=6023
|
||||
server.port=6688
|
||||
# 数据库配置
|
||||
#182.90.224.147
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/wisdomsitezw_hzxmgl?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useSSL=false
|
||||
spring.datasource.url=jdbc:mysql://139.9.66.234:3306/wisdomsitezw_hzxmgl?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useSSL=false
|
||||
# 数据库加密配置
|
||||
#spring.datasource.username=ENC(XR4C/hvTYCUqudS49Wh/jA==)
|
||||
#spring.datasource.password=ENC(hHkiHEc6vSWjqfOtg2/2Uiihs0vX3l7V)
|
||||
spring.datasource.username=root
|
||||
#spring.datasource.password=JXJ@admin
|
||||
spring.datasource.password=root
|
||||
spring.datasource.password=JXJ@admin
|
||||
#spring.datasource.password=root
|
||||
# 文件存储路径
|
||||
basePath=D:/itbgpImage/
|
||||
# 文件访问路径
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user