表数据查看增加选择展示列功能,域账号登录优化

This commit is contained in:
暮光:城中城
2021-09-25 21:28:37 +08:00
parent 27c0d8e50a
commit b82f6ae2e0
9 changed files with 106 additions and 67 deletions

View File

@@ -4,6 +4,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
@@ -21,14 +22,14 @@ import java.util.Optional;
@SpringBootApplication
@ComponentScan(basePackages = {"com.zyplayer.doc.manage", "com.zyplayer.doc.data"})
public class Application extends SpringBootServletInitializer {
private static Logger logger = LoggerFactory.getLogger(Application.class);
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) throws Exception {
ConfigurableApplicationContext application = SpringApplication.run(Application.class, args);
Environment env = application.getEnvironment();

View File

@@ -1,30 +0,0 @@
package com.zyplayer.doc.manage.framework.config;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.support.LdapContextSource;
@Configurable
public class LdapConfig {
String url = "ldap://10.0.1.1:10389";
String base = "dc=xx,dc=net";
String userDn = "cn=Manager,dc=xx,dc=net";
String password = "MKDSHYDNIS";
/**
* 初始化
*/
@Bean
public LdapTemplate getLdapTemplate() {
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl(url);
contextSource.setBase(base);
contextSource.setUserDn(userDn);
contextSource.setPassword(password);
contextSource.setPooled(false);
contextSource.afterPropertiesSet();
return new LdapTemplate(contextSource);
}
}

View File

@@ -46,8 +46,8 @@ public class LoginController {
// TODO 域账号登录,待测试
@Value("${spring.ldap.domainName:}")
private String ldapDomainName;
@Value("${spring.ldap.urls:}")
private String ldapUrls;
@Value("${spring.ldap.enable:}")
private boolean ldapLoginEnable;
/**
* 用户登录
@@ -59,7 +59,7 @@ public class LoginController {
queryWrapper.eq("del_flag", 0);
UserInfo userInfo = userInfoService.getOne(queryWrapper);
// 如果使用域账号登录
if (this.isUseLdapServer()) {
if (ldapLoginEnable) {
LdapPerson ldapPerson = this.getUserFromLdap(username, password);
if (null == ldapPerson) {
return DocResponseJson.warn("用户名或密码错误");
@@ -117,13 +117,6 @@ public class LoginController {
return userInfo;
}
/**
* 是否使用域账号登录
*/
public boolean isUseLdapServer() {
return StringUtils.isNotEmpty(ldapUrls);
}
/**
* 鉴别域账号中是否有该用户
*/

View File

@@ -10,6 +10,13 @@ spring:
datasource:
continue-on-error: true
ldap:
enable: false
urls: ['ldap://10.0.1.1:10389']
base: dc=xx,dc=net
username: cn=Manager,dc=xx,dc=net
password: MKDSHYDNIS
anonymousReadOnly: true
# 端口和根路劲main方法启动时需要放tomcat后以tomcat的配置为准
server: