用户管理及下拉选查询接口开发
This commit is contained in:
parent
c04db104e5
commit
dbf6c4592e
|
|
@ -4,6 +4,7 @@ import com.bonus.hnrn.rnbmw.basic.entity.SubContractorBean;
|
||||||
import com.bonus.hnrn.rnbmw.basic.service.ProjectService;
|
import com.bonus.hnrn.rnbmw.basic.service.ProjectService;
|
||||||
import com.bonus.hnrn.rnbmw.basic.service.SubContractorService;
|
import com.bonus.hnrn.rnbmw.basic.service.SubContractorService;
|
||||||
import com.bonus.hnrn.rnbmw.manager.annotation.LogAnnotation;
|
import com.bonus.hnrn.rnbmw.manager.annotation.LogAnnotation;
|
||||||
|
import com.bonus.hnrn.rnbmw.manager.config.FilePathConfig;
|
||||||
import com.bonus.hnrn.rnbmw.manager.table.PageTableHandler;
|
import com.bonus.hnrn.rnbmw.manager.table.PageTableHandler;
|
||||||
import com.bonus.hnrn.rnbmw.manager.table.PageTableRequest;
|
import com.bonus.hnrn.rnbmw.manager.table.PageTableRequest;
|
||||||
import com.bonus.hnrn.rnbmw.manager.table.PageTableResponse;
|
import com.bonus.hnrn.rnbmw.manager.table.PageTableResponse;
|
||||||
|
|
@ -39,6 +40,9 @@ public class SubContractorController {
|
||||||
@Resource(name = "ProjectService")
|
@Resource(name = "ProjectService")
|
||||||
private ProjectService proService;
|
private ProjectService proService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FilePathConfig filePathConfig;
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation(value = "分包商")
|
@ApiOperation(value = "分包商")
|
||||||
@PreAuthorize("hasAuthority('sys:SubContractor:query')")
|
@PreAuthorize("hasAuthority('sys:SubContractor:query')")
|
||||||
|
|
@ -214,15 +218,11 @@ public class SubContractorController {
|
||||||
if (StringHelper.isEmpty(tmpName)) {
|
if (StringHelper.isEmpty(tmpName)) {
|
||||||
return null; // 根据情况
|
return null; // 根据情况
|
||||||
}
|
}
|
||||||
|
String dataPath=filePathConfig.getAutoAdaptPath();
|
||||||
String suffix = tmpName.substring(tmpName.lastIndexOf("."));
|
String suffix = tmpName.substring(tmpName.lastIndexOf("."));
|
||||||
String fileName = DateTimeHelper.getNowDate().replace("-", "") + "_" + generateShortUuid() + "_" + tmpName;
|
String fileName = DateTimeHelper.getNowDate().replace("-", "") + "_" + generateShortUuid() + "_" + tmpName;
|
||||||
String mkdirsName = "subContractor"; // 委托需求
|
String mkdirsName = "subContractor"; // 委托需求
|
||||||
String Files = "/rdata/gz_real_name/" + mkdirsName + "/"; // linux 系统路径
|
String Files = dataPath + mkdirsName + "/"; // linux 系统路径
|
||||||
String os = System.getProperty("os.name");
|
|
||||||
if (os.toLowerCase().startsWith("win")) {
|
|
||||||
Files = "e://files/" + mkdirsName;
|
|
||||||
|
|
||||||
}
|
|
||||||
String path = Files + "/" + DateTimeHelper.getYear(new Date()) + "/" + DateTimeHelper.getMonth(new Date()) + "/"+DateTimeHelper.getDay()+"/" + fileName;
|
String path = Files + "/" + DateTimeHelper.getYear(new Date()) + "/" + DateTimeHelper.getMonth(new Date()) + "/"+DateTimeHelper.getDay()+"/" + fileName;
|
||||||
File file = new File(path);
|
File file = new File(path);
|
||||||
//生成文件夹
|
//生成文件夹
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.bonus.hnrn.rnbmw.manager.config;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class FilePathConfig {
|
||||||
|
|
||||||
|
@Value("${files.path}")
|
||||||
|
private String linuxPath;
|
||||||
|
|
||||||
|
@Value("${windows.path}")
|
||||||
|
private String windowsPath;
|
||||||
|
|
||||||
|
|
||||||
|
public String getAutoAdaptPath() {
|
||||||
|
// 获取系统名称(统一转小写,避免大小写问题)
|
||||||
|
String osName = System.getProperty("os.name").toLowerCase();
|
||||||
|
|
||||||
|
String targetPath;
|
||||||
|
// 判断系统类型
|
||||||
|
if (osName.contains("win")) {
|
||||||
|
// Windows系统(包含win7/win10/win11等)
|
||||||
|
targetPath = windowsPath;
|
||||||
|
} else if (osName.contains("nix") || osName.contains("nux") || osName.contains("mac")) {
|
||||||
|
// Linux/Unix/Mac系统(覆盖主流服务器系统)
|
||||||
|
targetPath = linuxPath;
|
||||||
|
} else {
|
||||||
|
// 兜底:未知系统默认使用Linux路径(可根据业务调整)
|
||||||
|
throw new RuntimeException("不支持的操作系统类型:" + osName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 路径标准化:统一分隔符、确保结尾有分隔符(避免拼接错误)
|
||||||
|
return Paths.get(targetPath).toFile().getAbsolutePath() + File.separator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.bonus.hnrn.rnbmw.manager.config;
|
package com.bonus.hnrn.rnbmw.manager.config;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.bonus.hnrn.rnbmw.manager.filter.ParamLengthInterceptor;
|
import com.bonus.hnrn.rnbmw.manager.filter.ParamLengthInterceptor;
|
||||||
|
|
@ -45,16 +46,45 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
||||||
* 上传文件根路径
|
* 上传文件根路径
|
||||||
*/
|
*/
|
||||||
@Value("${files.path}")
|
@Value("${files.path}")
|
||||||
private String filesPath;
|
private String linuxPath;
|
||||||
|
|
||||||
|
@Value("${windows.path}")
|
||||||
|
private String windowsPath;
|
||||||
/**
|
/**
|
||||||
* 外部文件访问
|
* 外部文件访问
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
|
String autoPath = getAutoAdaptPath();
|
||||||
registry.addResourceHandler("/gzRealName/**")
|
registry.addResourceHandler("/gzRealName/**")
|
||||||
.addResourceLocations(ResourceUtils.FILE_URL_PREFIX + filesPath );
|
.addResourceLocations(ResourceUtils.FILE_URL_PREFIX + autoPath );
|
||||||
registry.addResourceHandler("/statics/**")
|
registry.addResourceHandler("/statics/**")
|
||||||
.addResourceLocations(ResourceUtils.FILE_URL_PREFIX + filesPath + File.separator);
|
.addResourceLocations(ResourceUtils.FILE_URL_PREFIX + autoPath + File.separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断服务器环境
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String getAutoAdaptPath() {
|
||||||
|
// 获取系统名称(统一转小写,避免大小写问题)
|
||||||
|
String osName = System.getProperty("os.name").toLowerCase();
|
||||||
|
|
||||||
|
String targetPath;
|
||||||
|
// 判断系统类型
|
||||||
|
if (osName.contains("win")) {
|
||||||
|
// Windows系统(包含win7/win10/win11等)
|
||||||
|
targetPath = windowsPath;
|
||||||
|
} else if (osName.contains("nix") || osName.contains("nux") || osName.contains("mac")) {
|
||||||
|
// Linux/Unix/Mac系统(覆盖主流服务器系统)
|
||||||
|
targetPath = linuxPath;
|
||||||
|
} else {
|
||||||
|
// 兜底:未知系统默认使用Linux路径(可根据业务调整)
|
||||||
|
throw new RuntimeException("不支持的操作系统类型:" + osName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 路径标准化:统一分隔符、确保结尾有分隔符(避免拼接错误)
|
||||||
|
return Paths.get(targetPath).toFile().getAbsolutePath() + File.separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,9 @@ log:
|
||||||
files:
|
files:
|
||||||
path: /rdata/gz_real_name/
|
path: /rdata/gz_real_name/
|
||||||
upload_path: /rdata/gz_real_name
|
upload_path: /rdata/gz_real_name
|
||||||
|
windows:
|
||||||
|
path: F:/files/
|
||||||
|
upload_path: F:/files
|
||||||
token:
|
token:
|
||||||
expire:
|
expire:
|
||||||
seconds: 7200
|
seconds: 7200
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ public class PublicLoginController {
|
||||||
|
|
||||||
@PostMapping("getDeptTree")
|
@PostMapping("getDeptTree")
|
||||||
@ApiOperation(value = "获取部门树")
|
@ApiOperation(value = "获取部门树")
|
||||||
public AjaxRes getDeptTree() {
|
public AjaxRes getDeptTree(PublicUserVo vo) {
|
||||||
try{
|
try{
|
||||||
List<MapBean> result = userService.getRole();
|
List<MapBean> result = userService.getRole();
|
||||||
return AjaxRes.success(result);
|
return AjaxRes.success(result);
|
||||||
|
|
@ -74,7 +74,7 @@ public class PublicLoginController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("getRoleList")
|
@PostMapping("getRoleList")
|
||||||
@ApiOperation(value = "获取角色下拉选")
|
@ApiOperation(value = "获取角色下拉选")
|
||||||
public AjaxRes getRoleList() {
|
public AjaxRes getRoleList(PublicUserVo vo) {
|
||||||
AjaxRes ar = new AjaxRes();
|
AjaxRes ar = new AjaxRes();
|
||||||
try {
|
try {
|
||||||
List<ZNode> list = userService.getDepartmentTree();
|
List<ZNode> list = userService.getDepartmentTree();
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ package com.bns.ldlz.controller;
|
||||||
import com.bns.common.constant.Constants;
|
import com.bns.common.constant.Constants;
|
||||||
import com.bns.common.core.controller.BaseController;
|
import com.bns.common.core.controller.BaseController;
|
||||||
import com.bns.common.core.domain.AjaxResult;
|
import com.bns.common.core.domain.AjaxResult;
|
||||||
|
import com.bns.common.core.domain.TreeSelect;
|
||||||
import com.bns.common.core.domain.entity.SysDept;
|
import com.bns.common.core.domain.entity.SysDept;
|
||||||
import com.bns.common.core.domain.entity.SysRole;
|
import com.bns.common.core.domain.entity.SysRole;
|
||||||
import com.bns.ldlz.domain.LoginForm;
|
import com.bns.ldlz.domain.LoginForm;
|
||||||
|
|
@ -19,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -26,7 +28,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/publicLogin")
|
@RequestMapping(value = "/publicLogin")
|
||||||
public class PublicLoginController extends BaseController {
|
public class PublicLoginController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PublicLoginService loginService;
|
private PublicLoginService loginService;
|
||||||
|
|
@ -60,20 +62,21 @@ public class PublicLoginController extends BaseController {
|
||||||
|
|
||||||
@PostMapping("getDeptTree")
|
@PostMapping("getDeptTree")
|
||||||
@ApiOperation(value = "获取部门树")
|
@ApiOperation(value = "获取部门树")
|
||||||
public AjaxResult getDeptTree(@RequestBody SysDept dept) {
|
public AjaxResult getDeptTree(SysDept dept) {
|
||||||
return success(deptService.selectPublicDeptTreeList(dept));
|
List<TreeSelect> list=deptService.selectPublicDeptTreeList(dept);
|
||||||
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色下拉选
|
* 角色下拉选
|
||||||
* @param vo
|
* @param
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("getRoleList")
|
@PostMapping("getRoleList")
|
||||||
@ApiOperation(value = "获取角色下拉选")
|
@ApiOperation(value = "获取角色下拉选")
|
||||||
public AjaxResult getRoleList(@RequestBody PublicUserVo vo) {
|
public AjaxResult getRoleList() {
|
||||||
List<SysRole> roles = roleService.selectPublicRoleAll();
|
List<SysRole> roles = roleService.selectPublicRoleAll();
|
||||||
return success(roles);
|
return AjaxResult.success(roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,23 +51,23 @@ public class ResourcesConfig implements WebMvcConfigurer
|
||||||
/**
|
/**
|
||||||
* 跨域配置
|
* 跨域配置
|
||||||
*/
|
*/
|
||||||
@Bean
|
// @Bean
|
||||||
public CorsFilter corsFilter()
|
// public CorsFilter corsFilter()
|
||||||
{
|
// {
|
||||||
CorsConfiguration config = new CorsConfiguration();
|
// CorsConfiguration config = new CorsConfiguration();
|
||||||
config.setAllowCredentials(true);
|
// config.setAllowCredentials(true);
|
||||||
// 设置访问源地址
|
// // 设置访问源地址
|
||||||
config.addAllowedOrigin("*");
|
// config.addAllowedOrigin("*");
|
||||||
// 设置访问源请求头
|
// // 设置访问源请求头
|
||||||
config.addAllowedHeader("*");
|
// config.addAllowedHeader("*");
|
||||||
// 设置访问源请求方法
|
// // 设置访问源请求方法
|
||||||
config.addAllowedMethod("*");
|
// config.addAllowedMethod("*");
|
||||||
// 有效期 1800秒
|
// // 有效期 1800秒
|
||||||
config.setMaxAge(1800L);
|
// config.setMaxAge(1800L);
|
||||||
// 添加映射路径,拦截一切请求
|
// // 添加映射路径,拦截一切请求
|
||||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
// UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||||
source.registerCorsConfiguration("/**", config);
|
// source.registerCorsConfiguration("/**", config);
|
||||||
// 返回新的CorsFilter
|
// // 返回新的CorsFilter
|
||||||
return new CorsFilter(source);
|
// return new CorsFilter(source);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
@ -55,8 +55,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
||||||
/**
|
/**
|
||||||
* 跨域过滤器
|
* 跨域过滤器
|
||||||
*/
|
*/
|
||||||
@Autowired
|
// @Autowired
|
||||||
private CorsFilter corsFilter;
|
// private CorsFilter corsFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 允许匿名访问的地址
|
* 允许匿名访问的地址
|
||||||
|
|
@ -126,8 +126,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
||||||
// 添加JWT filter
|
// 添加JWT filter
|
||||||
httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
|
httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
|
||||||
// 添加CORS filter
|
// 添加CORS filter
|
||||||
httpSecurity.addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class);
|
// httpSecurity.addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class);
|
||||||
httpSecurity.addFilterBefore(corsFilter, LogoutFilter.class);
|
// httpSecurity.addFilterBefore(corsFilter, LogoutFilter.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue