.....
This commit is contained in:
parent
f9dbd1956d
commit
ac9fb347b4
29
pom.xml
29
pom.xml
@ -34,7 +34,7 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- jsp解析依赖,不加这个访问jsp直接变成下载 -->
|
<!-- jsp解析依赖,不加这个访问jsp直接变成下载 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
@ -53,7 +53,7 @@
|
|||||||
<artifactId>tomcat-jsp-api</artifactId>
|
<artifactId>tomcat-jsp-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- jsp解析依赖 end -->
|
<!-- jsp解析依赖 end -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
@ -74,7 +74,7 @@
|
|||||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
@ -105,14 +105,14 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-validation</artifactId>
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Druid Spring Boot Starter -->
|
<!-- Druid Spring Boot Starter -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>druid-spring-boot-starter</artifactId>
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
<version>${druid.springboot.version}</version>
|
<version>${druid.springboot.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--mapper-->
|
<!--mapper-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>tk.mybatis</groupId>
|
<groupId>tk.mybatis</groupId>
|
||||||
@ -126,7 +126,7 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--pagehelper-->
|
<!--pagehelper-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.pagehelper</groupId>
|
<groupId>com.github.pagehelper</groupId>
|
||||||
@ -170,18 +170,18 @@
|
|||||||
<artifactId>kaptcha</artifactId>
|
<artifactId>kaptcha</artifactId>
|
||||||
<version>2.3.2</version>
|
<version>2.3.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>${fastjson.version}</version>
|
<version>${fastjson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi</artifactId>
|
<artifactId>poi</artifactId>
|
||||||
@ -192,7 +192,7 @@
|
|||||||
<artifactId>poi-ooxml</artifactId>
|
<artifactId>poi-ooxml</artifactId>
|
||||||
<version>${poi.version}</version>
|
<version>${poi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ognl</groupId>
|
<groupId>ognl</groupId>
|
||||||
<artifactId>ognl</artifactId>
|
<artifactId>ognl</artifactId>
|
||||||
@ -209,8 +209,15 @@
|
|||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 整合 Elasticsearch -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- 测试用, 配置devtools实现热部署 -->
|
<!-- 测试用, 配置devtools实现热部署 -->
|
||||||
<!--
|
<!--
|
||||||
会导致ClassCastException异常
|
会导致ClassCastException异常
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|||||||
@ -89,7 +89,7 @@ public class MyShiroRealm extends AuthorizingRealm {
|
|||||||
return authenticationInfo;
|
return authenticationInfo;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//认证
|
//认证
|
||||||
@Override
|
@Override
|
||||||
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
|
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
|
||||||
@ -103,7 +103,7 @@ public class MyShiroRealm extends AuthorizingRealm {
|
|||||||
user.setUserId(syUsers.getUserName());
|
user.setUserId(syUsers.getUserName());
|
||||||
user.setUsername(syUsers.getUserName());
|
user.setUsername(syUsers.getUserName());
|
||||||
user.setPassword(syUsers.getUserPassword());
|
user.setPassword(syUsers.getUserPassword());
|
||||||
|
|
||||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||||
// 把ip放入user存入redis缓存里
|
// 把ip放入user存入redis缓存里
|
||||||
user.setLoginIpAddress(CommonUtils.getIpAddr(request));
|
user.setLoginIpAddress(CommonUtils.getIpAddr(request));
|
||||||
|
|||||||
@ -18,16 +18,16 @@ import com.nbclass.system.model.Permission;
|
|||||||
import com.nbclass.system.service.PermissionService;
|
import com.nbclass.system.service.PermissionService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Leon
|
* @author Leon
|
||||||
* @datetime 2019年4月1日 下午2:47:53
|
* @datetime 2019年4月1日 下午2:47:53
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ShiroService {
|
public class ShiroService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PermissionService permissionService;
|
private PermissionService permissionService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化加载权限
|
* 初始化加载权限
|
||||||
* @return
|
* @return
|
||||||
@ -35,7 +35,7 @@ public class ShiroService {
|
|||||||
public Map<String, String> loadFilterChainDefinitions() {
|
public Map<String, String> loadFilterChainDefinitions() {
|
||||||
// 权限控制map.从数据库获取
|
// 权限控制map.从数据库获取
|
||||||
Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();
|
Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
filterChainDefinitionMap.put("/register", "anon");
|
filterChainDefinitionMap.put("/register", "anon");
|
||||||
filterChainDefinitionMap.put("/login", "anon");
|
filterChainDefinitionMap.put("/login", "anon");
|
||||||
filterChainDefinitionMap.put("/error/**", "anon");
|
filterChainDefinitionMap.put("/error/**", "anon");
|
||||||
@ -47,7 +47,9 @@ public class ShiroService {
|
|||||||
filterChainDefinitionMap.put("/libs/**","anon");
|
filterChainDefinitionMap.put("/libs/**","anon");
|
||||||
filterChainDefinitionMap.put("/favicon.ico", "anon");
|
filterChainDefinitionMap.put("/favicon.ico", "anon");
|
||||||
filterChainDefinitionMap.put("/verificationCode", "anon");
|
filterChainDefinitionMap.put("/verificationCode", "anon");
|
||||||
|
|
||||||
|
filterChainDefinitionMap.put("/test/**", "anon");
|
||||||
|
|
||||||
filterChainDefinitionMap.put("/api/**" ,"anon"); // 前端接口
|
filterChainDefinitionMap.put("/api/**" ,"anon"); // 前端接口
|
||||||
filterChainDefinitionMap.put("/", "anon"); // 网站首页
|
filterChainDefinitionMap.put("/", "anon"); // 网站首页
|
||||||
// 静态资源按后缀排除
|
// 静态资源按后缀排除
|
||||||
@ -62,14 +64,14 @@ public class ShiroService {
|
|||||||
filterChainDefinitionMap.put("/**/*.woff2", "anon");
|
filterChainDefinitionMap.put("/**/*.woff2", "anon");
|
||||||
filterChainDefinitionMap.put("/**/*.mp3", "anon");
|
filterChainDefinitionMap.put("/**/*.mp3", "anon");
|
||||||
filterChainDefinitionMap.put("/**/*.mp4", "anon");
|
filterChainDefinitionMap.put("/**/*.mp4", "anon");
|
||||||
|
|
||||||
// filterChainDefinitionMap.put("/**/*.html", "authc,wxOAuthFilter");
|
// filterChainDefinitionMap.put("/**/*.html", "authc,wxOAuthFilter");
|
||||||
// filterChainDefinitionMap.put("/**/*.jsp", "authc,wxOAuthFilter");
|
// filterChainDefinitionMap.put("/**/*.jsp", "authc,wxOAuthFilter");
|
||||||
filterChainDefinitionMap.put("/**/*.html", "wxOAuthFilter");
|
filterChainDefinitionMap.put("/**/*.html", "wxOAuthFilter");
|
||||||
filterChainDefinitionMap.put("/mobile/page/**", "wxOAuthFilter");
|
filterChainDefinitionMap.put("/mobile/page/**", "wxOAuthFilter");
|
||||||
// 测试放开权限
|
// 测试放开权限
|
||||||
filterChainDefinitionMap.put("/mobile/api/**", "anon");
|
filterChainDefinitionMap.put("/mobile/api/**", "anon");
|
||||||
|
|
||||||
//List<Permission> permissionList = permissionService.selectAll(CoreConst.STATUS_VALID); // 迁移此数据库结构不一致,不从数据库查权限配置
|
//List<Permission> permissionList = permissionService.selectAll(CoreConst.STATUS_VALID); // 迁移此数据库结构不一致,不从数据库查权限配置
|
||||||
List<Permission> permissionList = new ArrayList<Permission>();
|
List<Permission> permissionList = new ArrayList<Permission>();
|
||||||
for(Permission permission : permissionList){
|
for(Permission permission : permissionList){
|
||||||
@ -78,9 +80,9 @@ public class ShiroService {
|
|||||||
filterChainDefinitionMap.put(permission.getUrl(),perm+",kickout");
|
filterChainDefinitionMap.put(permission.getUrl(),perm+",kickout");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filterChainDefinitionMap.put("/**", "user,kickout");
|
filterChainDefinitionMap.put("/**", "user,kickout");
|
||||||
|
|
||||||
return filterChainDefinitionMap;
|
return filterChainDefinitionMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -93,7 +93,7 @@ public class ShiroConfig {
|
|||||||
filtersMap.put("kickout", kickoutSessionControlFilter());
|
filtersMap.put("kickout", kickoutSessionControlFilter());
|
||||||
// 企业微信登录拦截器
|
// 企业微信登录拦截器
|
||||||
filtersMap.put("wxOAuthFilter", new WxWorkFilter());
|
filtersMap.put("wxOAuthFilter", new WxWorkFilter());
|
||||||
|
|
||||||
shiroFilterFactoryBean.setFilters(filtersMap);
|
shiroFilterFactoryBean.setFilters(filtersMap);
|
||||||
//拦截器.
|
//拦截器.
|
||||||
Map<String,String> filterChainDefinitionMap = shiroService.loadFilterChainDefinitions();
|
Map<String,String> filterChainDefinitionMap = shiroService.loadFilterChainDefinitions();
|
||||||
@ -244,7 +244,7 @@ public class ShiroConfig {
|
|||||||
return kickoutSessionControlFilter;
|
return kickoutSessionControlFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static byte[] getCipherKey(){
|
private static byte[] getCipherKey(){
|
||||||
byte[] cipherKey = null;
|
byte[] cipherKey = null;
|
||||||
KeyGenerator keygen = null;
|
KeyGenerator keygen = null;
|
||||||
@ -257,9 +257,9 @@ public class ShiroConfig {
|
|||||||
}
|
}
|
||||||
return cipherKey;
|
return cipherKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
System.out.println("cipherKey="+Base64.encodeToString(getCipherKey()));
|
System.out.println("cipherKey="+Base64.encodeToString(getCipherKey()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -133,7 +133,7 @@ public class SystemController{
|
|||||||
return ResultUtil.error("用户名或者密码错误!");
|
return ResultUtil.error("用户名或者密码错误!");
|
||||||
}
|
}
|
||||||
//更新最后登录时间
|
//更新最后登录时间
|
||||||
userService.updateLastLoginTime((User) SecurityUtils.getSubject().getPrincipal());
|
// userService.updateLastLoginTime((User) SecurityUtils.getSubject().getPrincipal());
|
||||||
return ResultUtil.success("登录成功!");
|
return ResultUtil.success("登录成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
126
src/main/java/com/nbclass/szxgl/config/BackDataBaseConfig.java
Normal file
126
src/main/java/com/nbclass/szxgl/config/BackDataBaseConfig.java
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
package com.nbclass.szxgl.config;
|
||||||
|
|
||||||
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName
|
||||||
|
* @Description: 后台数据源配置类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "back.datasource.druid")
|
||||||
|
@MapperScan(basePackages = BackDataBaseConfig.PACKAGE, sqlSessionFactoryRef = "backSqlSessionFactory")
|
||||||
|
public class BackDataBaseConfig {
|
||||||
|
/**
|
||||||
|
* dao层的包路径
|
||||||
|
*/
|
||||||
|
static final String PACKAGE = "com.nbclass.szxgl.mapper2";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mapper文件的相对路径
|
||||||
|
*/
|
||||||
|
private static final String MAPPER_LOCATION = "classpath*:mapper/szxgl/*.xml";
|
||||||
|
|
||||||
|
@Value("${back.datasource.druid.filters}")
|
||||||
|
private String filters;
|
||||||
|
@Value("${back.datasource.druid.driverClassName}")
|
||||||
|
private String url;
|
||||||
|
@Value("${back.datasource.druid.url}")
|
||||||
|
private String username;
|
||||||
|
@Value("${back.datasource.druid.username}")
|
||||||
|
private String password;
|
||||||
|
@Value("${back.datasource.druid.password}")
|
||||||
|
private String driverClassName;
|
||||||
|
@Value("${back.datasource.druid.initialSize}")
|
||||||
|
private int initialSize;
|
||||||
|
@Value("${back.datasource.druid.minIdle}")
|
||||||
|
private int minIdle;
|
||||||
|
@Value("${back.datasource.druid.maxActive}")
|
||||||
|
private int maxActive;
|
||||||
|
@Value("${back.datasource.druid.maxWait}")
|
||||||
|
private long maxWait;
|
||||||
|
@Value("${back.datasource.druid.timeBetweenEvictionRunsMillis}")
|
||||||
|
private long timeBetweenEvictionRunsMillis;
|
||||||
|
@Value("${back.datasource.druid.minEvictableIdleTimeMillis}")
|
||||||
|
private long minEvictableIdleTimeMillis;
|
||||||
|
@Value("${back.datasource.druid.validationQuery}")
|
||||||
|
private String validationQuery;
|
||||||
|
@Value("${back.datasource.druid.testWhileIdle}")
|
||||||
|
private boolean testWhileIdle;
|
||||||
|
@Value("${back.datasource.druid.testOnBorrow}")
|
||||||
|
private boolean testOnBorrow;
|
||||||
|
@Value("${back.datasource.druid.testOnReturn}")
|
||||||
|
private boolean testOnReturn;
|
||||||
|
@Value("${back.datasource.druid.poolPreparedStatements}")
|
||||||
|
private boolean poolPreparedStatements;
|
||||||
|
@Value("${back.datasource.druid.maxPoolPreparedStatementPerConnectionSize}")
|
||||||
|
private int maxPoolPreparedStatementPerConnectionSize;
|
||||||
|
|
||||||
|
|
||||||
|
@Bean(name = "backDataSource")
|
||||||
|
public DataSource backDataSource() throws SQLException {
|
||||||
|
DruidDataSource druid = new DruidDataSource();
|
||||||
|
// 监控统计拦截的filters
|
||||||
|
druid.setFilters(filters);
|
||||||
|
|
||||||
|
// 配置基本属性
|
||||||
|
druid.setDriverClassName(driverClassName);
|
||||||
|
druid.setUsername(username);
|
||||||
|
druid.setPassword(password);
|
||||||
|
druid.setUrl(url);
|
||||||
|
|
||||||
|
//初始化时建立物理连接的个数
|
||||||
|
druid.setInitialSize(initialSize);
|
||||||
|
//最大连接池数量
|
||||||
|
druid.setMaxActive(maxActive);
|
||||||
|
//最小连接池数量
|
||||||
|
druid.setMinIdle(minIdle);
|
||||||
|
//获取连接时最大等待时间,单位毫秒。
|
||||||
|
druid.setMaxWait(maxWait);
|
||||||
|
//间隔多久进行一次检测,检测需要关闭的空闲连接
|
||||||
|
druid.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
|
||||||
|
//一个连接在池中最小生存的时间
|
||||||
|
druid.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
|
||||||
|
//用来检测连接是否有效的sql
|
||||||
|
druid.setValidationQuery(validationQuery);
|
||||||
|
//建议配置为true,不影响性能,并且保证安全性。
|
||||||
|
druid.setTestWhileIdle(testWhileIdle);
|
||||||
|
//申请连接时执行validationQuery检测连接是否有效
|
||||||
|
druid.setTestOnBorrow(testOnBorrow);
|
||||||
|
druid.setTestOnReturn(testOnReturn);
|
||||||
|
//是否缓存preparedStatement,也就是PSCache,oracle设为true,mysql设为false。分库分表较多推荐设置为false
|
||||||
|
druid.setPoolPreparedStatements(poolPreparedStatements);
|
||||||
|
// 打开PSCache时,指定每个连接上PSCache的大小
|
||||||
|
druid.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
|
||||||
|
return druid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "backTransactionManager")
|
||||||
|
public DataSourceTransactionManager backTransactionManager() throws SQLException {
|
||||||
|
return new DataSourceTransactionManager(backDataSource());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "backSqlSessionFactory")
|
||||||
|
public SqlSessionFactory backSqlSessionFactory(@Qualifier("backDataSource") DataSource backDataSource) throws Exception {
|
||||||
|
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
||||||
|
sessionFactory.setDataSource(backDataSource);
|
||||||
|
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
|
||||||
|
.getResources(BackDataBaseConfig.MAPPER_LOCATION));
|
||||||
|
|
||||||
|
return sessionFactory.getObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
47
src/main/java/com/nbclass/szxgl/config/DataSourceConfig.java
Normal file
47
src/main/java/com/nbclass/szxgl/config/DataSourceConfig.java
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package com.nbclass.szxgl.config;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多数据源配置
|
||||||
|
*/
|
||||||
|
//@Configuration
|
||||||
|
//public class DataSourceConfig {
|
||||||
|
//
|
||||||
|
// //主数据源配置 ds1数据源
|
||||||
|
// @Primary
|
||||||
|
// @Bean(name = "ds1DataSourceProperties")
|
||||||
|
// @ConfigurationProperties(prefix = "fastdep.datasource.test")
|
||||||
|
// public DataSourceProperties ds1DataSourceProperties() {
|
||||||
|
// return new DataSourceProperties();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //主数据源 ds1数据源
|
||||||
|
// @Primary
|
||||||
|
// @Bean(name = "ds1DataSource")
|
||||||
|
// public DataSource ds1DataSource(@Qualifier("ds1DataSourceProperties") DataSourceProperties dataSourceProperties) {
|
||||||
|
//
|
||||||
|
// return dataSourceProperties.initializeDataSourceBuilder().build();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //第二个ds2数据源配置
|
||||||
|
// @Bean(name = "ds2DataSourceProperties")
|
||||||
|
// @ConfigurationProperties(prefix = "fastdep.datasource.test2")
|
||||||
|
// public DataSourceProperties ds2DataSourceProperties() {
|
||||||
|
// return new DataSourceProperties();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //第二个ds2数据源
|
||||||
|
// @Bean("ds2DataSource")
|
||||||
|
// public DataSource ds2DataSource(@Qualifier("ds2DataSourceProperties") DataSourceProperties dataSourceProperties) {
|
||||||
|
// return dataSourceProperties.initializeDataSourceBuilder().build();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package com.nbclass.szxgl.config;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JdbcTemplate多数据源配置
|
||||||
|
* 依赖于数据源配置
|
||||||
|
*
|
||||||
|
* @see DataSourceConfig
|
||||||
|
*/
|
||||||
|
//@Configuration
|
||||||
|
//public class JdbcTemplateDataSourceConfig {
|
||||||
|
//
|
||||||
|
// //JdbcTemplate主数据源ds1数据源
|
||||||
|
// @Primary
|
||||||
|
// @Bean(name = "ds1JdbcTemplate")
|
||||||
|
// public JdbcTemplate ds1JdbcTemplate(@Qualifier("ds1DataSource") DataSource dataSource) {
|
||||||
|
// return new JdbcTemplate(dataSource);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //JdbcTemplate第二个ds2数据源
|
||||||
|
// @Bean(name = "ds2JdbcTemplate")
|
||||||
|
// public JdbcTemplate ds2JdbcTemplate(@Qualifier("ds2DataSource") DataSource dataSource) {
|
||||||
|
// return new JdbcTemplate(dataSource);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
package com.nbclass.szxgl.config;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||||
|
import org.mybatis.spring.SqlSessionTemplate;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mybatis主数据源ds1配置
|
||||||
|
* 多数据源配置依赖数据源配置
|
||||||
|
* @see DataSourceConfig
|
||||||
|
*/
|
||||||
|
//@Configuration
|
||||||
|
//@MapperScan(basePackages ="com.nbclass.szxgl.mapper", sqlSessionTemplateRef = "ds1SqlSessionTemplate")
|
||||||
|
//public class MybatisPlusConfig4ds1 {
|
||||||
|
//
|
||||||
|
// //主数据源 ds1数据源
|
||||||
|
// @Primary
|
||||||
|
// @Bean("ds1SqlSessionFactory")
|
||||||
|
// public SqlSessionFactory ds1SqlSessionFactory(@Qualifier("ds1DataSource") DataSource dataSource) throws Exception {
|
||||||
|
// SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean();
|
||||||
|
// sqlSessionFactory.setDataSource(dataSource);
|
||||||
|
// sqlSessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().
|
||||||
|
// getResources("classpath*:mapper/szxgl/*.xml"));
|
||||||
|
// return sqlSessionFactory.getObject();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Primary
|
||||||
|
// @Bean(name = "ds1TransactionManager")
|
||||||
|
// public DataSourceTransactionManager ds1TransactionManager(@Qualifier("ds1DataSource") DataSource dataSource) {
|
||||||
|
// return new DataSourceTransactionManager(dataSource);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Primary
|
||||||
|
// @Bean(name = "ds1SqlSessionTemplate")
|
||||||
|
// public SqlSessionTemplate ds1SqlSessionTemplate(@Qualifier("ds1SqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
|
||||||
|
// return new SqlSessionTemplate(sqlSessionFactory);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
package com.nbclass.szxgl.config;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||||
|
import org.mybatis.spring.SqlSessionTemplate;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mybatis 第二个ds2数据源配置
|
||||||
|
* 多数据源配置依赖数据源配置
|
||||||
|
* @see DataSourceConfig
|
||||||
|
*/
|
||||||
|
//@Configuration
|
||||||
|
//@MapperScan(basePackages ="com.nbclass.szxgl.mapper2", sqlSessionTemplateRef = "ds2SqlSessionTemplate")
|
||||||
|
//public class MybatisPlusConfig4ds2 {
|
||||||
|
//
|
||||||
|
// //ds2数据源
|
||||||
|
// @Bean("ds2SqlSessionFactory")
|
||||||
|
// public SqlSessionFactory ds2SqlSessionFactory(@Qualifier("ds2DataSource") DataSource dataSource) throws Exception {
|
||||||
|
// SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean();
|
||||||
|
// sqlSessionFactory.setDataSource(dataSource);
|
||||||
|
// sqlSessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().
|
||||||
|
// getResources("classpath*:mapper/szxgl/*.xml"));
|
||||||
|
// return sqlSessionFactory.getObject();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
////事务支持
|
||||||
|
// @Bean(name = "ds2TransactionManager")
|
||||||
|
// public DataSourceTransactionManager ds2TransactionManager(@Qualifier("ds2DataSource") DataSource dataSource) {
|
||||||
|
// return new DataSourceTransactionManager(dataSource);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Bean(name = "ds2SqlSessionTemplate")
|
||||||
|
// public SqlSessionTemplate ds2SqlSessionTemplate(@Qualifier("ds2SqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
|
||||||
|
// return new SqlSessionTemplate(sqlSessionFactory);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
@ -0,0 +1,123 @@
|
|||||||
|
package com.nbclass.szxgl.config;
|
||||||
|
|
||||||
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 主数据源配置类
|
||||||
|
* 前缀为primary.datasource.druid的配置信息
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "primary.datasource.druid")
|
||||||
|
@MapperScan(basePackages = PrimaryDataBaseConfig.PACKAGE, sqlSessionFactoryRef = "primarySqlSessionFactory")
|
||||||
|
public class PrimaryDataBaseConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dao层的包路径
|
||||||
|
*/
|
||||||
|
static final String PACKAGE = "com.nbclass.szxgl.mapper";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mapper文件的相对路径
|
||||||
|
*/
|
||||||
|
private static final String MAPPER_LOCATION = "classpath*:mapper/szxgl/*.xml";
|
||||||
|
|
||||||
|
private String filters;
|
||||||
|
private String url;
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
private String driverClassName;
|
||||||
|
private int initialSize;
|
||||||
|
private int minIdle;
|
||||||
|
private int maxActive;
|
||||||
|
private long maxWait;
|
||||||
|
private long timeBetweenEvictionRunsMillis;
|
||||||
|
private long minEvictableIdleTimeMillis;
|
||||||
|
private String validationQuery;
|
||||||
|
private boolean testWhileIdle;
|
||||||
|
private boolean testOnBorrow;
|
||||||
|
private boolean testOnReturn;
|
||||||
|
private boolean poolPreparedStatements;
|
||||||
|
private int maxPoolPreparedStatementPerConnectionSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主数据源使用@Primary注解进行标识
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Primary
|
||||||
|
@Bean(name = "primaryDataSource")
|
||||||
|
public DataSource primaryDataSource() throws SQLException {
|
||||||
|
DruidDataSource druid = new DruidDataSource();
|
||||||
|
// 监控统计拦截的filters
|
||||||
|
druid.setFilters(filters);
|
||||||
|
|
||||||
|
// 配置基本属性
|
||||||
|
druid.setDriverClassName(driverClassName);
|
||||||
|
druid.setUsername(username);
|
||||||
|
druid.setPassword(password);
|
||||||
|
druid.setUrl(url);
|
||||||
|
|
||||||
|
//初始化时建立物理连接的个数
|
||||||
|
druid.setInitialSize(initialSize);
|
||||||
|
//最大连接池数量
|
||||||
|
druid.setMaxActive(maxActive);
|
||||||
|
//最小连接池数量
|
||||||
|
druid.setMinIdle(minIdle);
|
||||||
|
//获取连接时最大等待时间,单位毫秒。
|
||||||
|
druid.setMaxWait(maxWait);
|
||||||
|
//间隔多久进行一次检测,检测需要关闭的空闲连接
|
||||||
|
druid.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
|
||||||
|
//一个连接在池中最小生存的时间
|
||||||
|
druid.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
|
||||||
|
//用来检测连接是否有效的sql
|
||||||
|
druid.setValidationQuery(validationQuery);
|
||||||
|
//建议配置为true,不影响性能,并且保证安全性。
|
||||||
|
druid.setTestWhileIdle(testWhileIdle);
|
||||||
|
//申请连接时执行validationQuery检测连接是否有效
|
||||||
|
druid.setTestOnBorrow(testOnBorrow);
|
||||||
|
druid.setTestOnReturn(testOnReturn);
|
||||||
|
//是否缓存preparedStatement,也就是PSCache,oracle设为true,mysql设为false。分库分表较多推荐设置为false
|
||||||
|
druid.setPoolPreparedStatements(poolPreparedStatements);
|
||||||
|
// 打开PSCache时,指定每个连接上PSCache的大小
|
||||||
|
druid.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
|
||||||
|
|
||||||
|
return druid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建该数据源的事务管理
|
||||||
|
*/
|
||||||
|
@Primary
|
||||||
|
@Bean(name = "primaryTransactionManager")
|
||||||
|
public DataSourceTransactionManager primaryTransactionManager() throws SQLException {
|
||||||
|
return new DataSourceTransactionManager(primaryDataSource());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建Mybatis的连接会话工厂实例
|
||||||
|
*/
|
||||||
|
@Primary
|
||||||
|
@Bean(name = "primarySqlSessionFactory")
|
||||||
|
public SqlSessionFactory primarySqlSessionFactory(@Qualifier("primaryDataSource") DataSource primaryDataSource) throws Exception {
|
||||||
|
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
||||||
|
sessionFactory.setDataSource(primaryDataSource); // 设置数据源bean
|
||||||
|
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
|
||||||
|
.getResources(PrimaryDataBaseConfig.MAPPER_LOCATION)); // 设置mapper文件路径
|
||||||
|
|
||||||
|
return sessionFactory.getObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package com.nbclass.szxgl.controller;
|
||||||
|
|
||||||
|
import com.nbclass.szxgl.service.TestService;
|
||||||
|
import com.nbclass.util.ResultUtil;
|
||||||
|
import com.nbclass.vo.base.ResponseVo;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/test")
|
||||||
|
public class TestController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TestService testService;
|
||||||
|
|
||||||
|
@GetMapping("/getContent")
|
||||||
|
public ResponseVo getContent(){
|
||||||
|
return ResultUtil.success(testService.getContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
package com.nbclass.szxgl.controller.mobile;
|
||||||
|
|
||||||
|
import com.nbclass.system.controller.BaseController;
|
||||||
|
import com.nbclass.szxgl.mapper2.DataDictItemMapper;
|
||||||
|
import com.nbclass.szxgl.service.ElasticSearchService;
|
||||||
|
import com.nbclass.util.ResultUtil;
|
||||||
|
import com.nbclass.vo.base.ResponseVo;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api")
|
||||||
|
public class ElasticSearchController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ElasticSearchService elasticSearchService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DataDictItemMapper dataDictItemMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全文检索
|
||||||
|
* @param tagIds 标签
|
||||||
|
* @param caseName 项目名称
|
||||||
|
* @param pageNum
|
||||||
|
* @param pageSize
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/getCaseName")
|
||||||
|
public ResponseVo getCaseName(String tagIds,String caseName,Integer pageNum, Integer pageSize){
|
||||||
|
Map<String, Object> map = elasticSearchService.getList(tagIds,caseName, pageNum, pageSize);
|
||||||
|
return ResultUtil.success(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据参数模糊匹配标签
|
||||||
|
* @param tagNames
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/getCaseTags")
|
||||||
|
public ResponseVo getCaseTags(String tagNames){
|
||||||
|
List<Map<String,Object>> list = dataDictItemMapper.getTagNames(tagNames);
|
||||||
|
return ResultUtil.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -30,7 +30,7 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Leon
|
* @author Leon
|
||||||
* @datetime 2019年4月24日 下午4:27:39
|
* @datetime 2019年4月24日 下午4:27:39
|
||||||
*/
|
*/
|
||||||
@ -53,7 +53,7 @@ public class ProjectController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取项目列表
|
* 获取项目列表
|
||||||
*
|
*
|
||||||
* @param entity
|
* @param entity
|
||||||
* @param limit 每页数量
|
* @param limit 每页数量
|
||||||
* @param offset 页码
|
* @param offset 页码
|
||||||
@ -100,7 +100,7 @@ public class ProjectController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID查询项目详情记录
|
* 根据ID查询项目详情记录
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/findById")
|
@RequestMapping("/findById")
|
||||||
@ -112,7 +112,7 @@ public class ProjectController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取项目任务列表
|
* 获取项目任务列表
|
||||||
*
|
*
|
||||||
* @param pid
|
* @param pid
|
||||||
* @param limit
|
* @param limit
|
||||||
* @param offset
|
* @param offset
|
||||||
@ -136,7 +136,7 @@ public class ProjectController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取项目任务进度日志列表
|
* 获取项目任务进度日志列表
|
||||||
*
|
*
|
||||||
* @param taskId
|
* @param taskId
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
@ -166,7 +166,7 @@ public class ProjectController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加项目
|
* 添加项目
|
||||||
*
|
*
|
||||||
* @param p
|
* @param p
|
||||||
* @param errors
|
* @param errors
|
||||||
* @param isSendMsg
|
* @param isSendMsg
|
||||||
@ -278,4 +278,5 @@ public class ProjectController extends BaseController {
|
|||||||
service.updateProjectStatus(id, contractno, status);
|
service.updateProjectStatus(id, contractno, status);
|
||||||
return ResultUtil.success("success");
|
return ResultUtil.success("success");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,8 @@ import com.nbclass.exception.ParameterException;
|
|||||||
import com.nbclass.holder.SpringContextHolder;
|
import com.nbclass.holder.SpringContextHolder;
|
||||||
import com.nbclass.system.controller.BaseController;
|
import com.nbclass.system.controller.BaseController;
|
||||||
import com.nbclass.system.model.User;
|
import com.nbclass.system.model.User;
|
||||||
|
import com.nbclass.szxgl.mapper.ListTypeMapper;
|
||||||
|
import com.nbclass.szxgl.model.ListType;
|
||||||
import com.nbclass.szxgl.model.ProjectTask;
|
import com.nbclass.szxgl.model.ProjectTask;
|
||||||
import com.nbclass.szxgl.model.ProjectTaskJournal;
|
import com.nbclass.szxgl.model.ProjectTaskJournal;
|
||||||
import com.nbclass.szxgl.service.ProjectService;
|
import com.nbclass.szxgl.service.ProjectService;
|
||||||
@ -20,10 +22,8 @@ import org.springframework.beans.propertyeditors.CustomDateEditor;
|
|||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.validation.Errors;
|
import org.springframework.validation.Errors;
|
||||||
import org.springframework.web.bind.WebDataBinder;
|
import org.springframework.web.bind.WebDataBinder;
|
||||||
import org.springframework.web.bind.annotation.InitBinder;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@ -45,6 +45,9 @@ public class ProjectTaskController extends BaseController {
|
|||||||
@Resource
|
@Resource
|
||||||
private ProjectTaskService projectTaskService;
|
private ProjectTaskService projectTaskService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ListTypeMapper listTypeMapper;
|
||||||
|
|
||||||
@InitBinder
|
@InitBinder
|
||||||
public void initBinder(WebDataBinder binder) {
|
public void initBinder(WebDataBinder binder) {
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||||
@ -119,11 +122,11 @@ public class ProjectTaskController extends BaseController {
|
|||||||
|
|
||||||
@RequestMapping("add")
|
@RequestMapping("add")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseVo add(@Valid ProjectTask t, Errors errors, Integer isSendMsg, String[] userIds) {
|
public ResponseVo add(@Valid ProjectTask t, Errors errors, Integer isSendMsg, String[] userIds,String listValues) {
|
||||||
if (errors.hasErrors()) {
|
if (errors.hasErrors()) {
|
||||||
return ResultUtil.error("参数验证失败");
|
return ResultUtil.error("参数验证失败");
|
||||||
}
|
}
|
||||||
projectTaskService.addProjectTask(t, isSendMsg, userIds);
|
projectTaskService.addProjectTask(t, isSendMsg, userIds,listValues);
|
||||||
return ResultUtil.success("success");
|
return ResultUtil.success("success");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,4 +198,16 @@ public class ProjectTaskController extends BaseController {
|
|||||||
projectTaskService.addProjectTaskJournal(j, speed);
|
projectTaskService.addProjectTaskJournal(j, speed);
|
||||||
return ResultUtil.success("success");
|
return ResultUtil.success("success");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取下拉列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/myTask/getComboBox")
|
||||||
|
@ResponseBody
|
||||||
|
public ResponseVo getComboBox(){
|
||||||
|
List<ListType> listTypes = listTypeMapper.getComboBox();
|
||||||
|
return ResultUtil.success(listTypes);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,78 +31,78 @@ import com.nbclass.util.HttpUtils;
|
|||||||
*/
|
*/
|
||||||
/*@WebFilter("*.html")*/
|
/*@WebFilter("*.html")*/
|
||||||
public class WxWorkFilter implements Filter {
|
public class WxWorkFilter implements Filter {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(WxWorkFilter.class);
|
private static final Logger logger = LoggerFactory.getLogger(WxWorkFilter.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain)
|
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain)
|
||||||
throws IOException, ServletException {
|
throws IOException, ServletException {
|
||||||
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||||
response.setHeader("Cache-Control", "no-store");
|
// response.setHeader("Cache-Control", "no-store");
|
||||||
|
//
|
||||||
String httpRequestFullURL = getHttpRequestFullURL(request);
|
// String httpRequestFullURL = getHttpRequestFullURL(request);
|
||||||
String redirect_uri = ActivityConstants.qywx_api_domain + "/api/oauth?agentid="+ActivityConstants.qywx_agentid+"&redirect_uri="+httpRequestFullURL;
|
// String redirect_uri = ActivityConstants.qywx_api_domain + "/api/oauth?agentid="+ActivityConstants.qywx_agentid+"&redirect_uri="+httpRequestFullURL;
|
||||||
|
//
|
||||||
Subject subject = SecurityUtils.getSubject();
|
// Subject subject = SecurityUtils.getSubject();
|
||||||
|
//
|
||||||
// String userkey = (String) request.getSession().getAttribute(ActivityConstants.session_key_user_id);
|
// // String userkey = (String) request.getSession().getAttribute(ActivityConstants.session_key_user_id);
|
||||||
// logger.info("[企业微信授权拦截器] userkey="+userkey+", requrl: "+httpRequestFullURL);
|
// // logger.info("[企业微信授权拦截器] userkey="+userkey+", requrl: "+httpRequestFullURL);
|
||||||
|
//
|
||||||
if(subject.isAuthenticated()){ // 已登录状态
|
// if(subject.isAuthenticated()){ // 已登录状态
|
||||||
chain.doFilter(request, response);
|
// chain.doFilter(request, response);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
String key = StringUtils.trimToEmpty(request.getParameter("key"));
|
// String key = StringUtils.trimToEmpty(request.getParameter("key"));
|
||||||
if("xglgg".equals(key)){ // 测试时传key绕过登录
|
// if("xglgg".equals(key)){ // 测试时传key绕过登录
|
||||||
MyUsernamePasswordToken token = new MyUsernamePasswordToken("liixi"); // 免密登录
|
// MyUsernamePasswordToken token = new MyUsernamePasswordToken("liixi"); // 免密登录
|
||||||
token.setRememberMe(true);
|
// token.setRememberMe(true);
|
||||||
try {
|
// try {
|
||||||
subject.login(token);
|
// subject.login(token);
|
||||||
} catch (AuthenticationException e) {
|
// } catch (AuthenticationException e) {
|
||||||
outPrintError(response, "该登录账号不存在,如有疑问请联系企业管理员!");
|
// outPrintError(response, "该登录账号不存在,如有疑问请联系企业管理员!");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
chain.doFilter(request, response);
|
// chain.doFilter(request, response);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
String code = request.getParameter("code");
|
// String code = request.getParameter("code");
|
||||||
if(StringUtils.isBlank(code)){
|
// if(StringUtils.isBlank(code)){
|
||||||
response.sendRedirect(redirect_uri);
|
// response.sendRedirect(redirect_uri);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
String url = ActivityConstants.qywx_api_domain + "/api/oauthInfo?agentid="+ActivityConstants.qywx_agentid+"&code=" + code;
|
// String url = ActivityConstants.qywx_api_domain + "/api/oauthInfo?agentid="+ActivityConstants.qywx_agentid+"&code=" + code;
|
||||||
JSONObject result = HttpUtils.httpGet(url);
|
// JSONObject result = HttpUtils.httpGet(url);
|
||||||
if(result != null && result.getIntValue("ret") == 0 && StringUtils.isNotBlank(result.getString("userid"))
|
// if(result != null && result.getIntValue("ret") == 0 && StringUtils.isNotBlank(result.getString("userid"))
|
||||||
&& !"null".equalsIgnoreCase(result.getString("userid"))){
|
// && !"null".equalsIgnoreCase(result.getString("userid"))){
|
||||||
logger.info("企业微信授权获取到用户信息: "+result.toString());
|
// logger.info("企业微信授权获取到用户信息: "+result.toString());
|
||||||
String userid = result.getString("userid");
|
// String userid = result.getString("userid");
|
||||||
request.getSession().setAttribute(ActivityConstants.session_key_user_id, userid);
|
// request.getSession().setAttribute(ActivityConstants.session_key_user_id, userid);
|
||||||
|
//
|
||||||
// OA系统shiro登录
|
// // OA系统shiro登录
|
||||||
MyUsernamePasswordToken token = new MyUsernamePasswordToken(userid); // 免密登录
|
// MyUsernamePasswordToken token = new MyUsernamePasswordToken(userid); // 免密登录
|
||||||
token.setRememberMe(true);
|
// token.setRememberMe(true);
|
||||||
try {
|
// try {
|
||||||
subject.login(token);
|
// subject.login(token);
|
||||||
} catch (AuthenticationException e) {
|
// } catch (AuthenticationException e) {
|
||||||
outPrintError(response, "该登录账号不存在,如有疑问请联系企业管理员!");
|
// outPrintError(response, "该登录账号不存在,如有疑问请联系企业管理员!");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}else{
|
// }else{
|
||||||
if(result!=null && (result.getIntValue("errcode") == 40029 || result.getIntValue("errcode") == 40163)){
|
// if(result!=null && (result.getIntValue("errcode") == 40029 || result.getIntValue("errcode") == 40163)){
|
||||||
logger.info("授权失败, 将重新跳转到微信授权, RedirectURL : " + redirect_uri);
|
// logger.info("授权失败, 将重新跳转到微信授权, RedirectURL : " + redirect_uri);
|
||||||
redirect_uri = CommonUtils.removeParamValue(redirect_uri, "code");
|
// redirect_uri = CommonUtils.removeParamValue(redirect_uri, "code");
|
||||||
response.sendRedirect(redirect_uri);
|
// response.sendRedirect(redirect_uri);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
outPrintError(response, "微信授权失败,你可能未关注该企业号,请关注后重试!");
|
// outPrintError(response, "微信授权失败,你可能未关注该企业号,请关注后重试!");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ public class WxWorkFilter implements Filter {
|
|||||||
return requestURL.append('?').append(queryString).toString();
|
return requestURL.append('?').append(queryString).toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 输出错误信息到页面
|
* 输出错误信息到页面
|
||||||
* @param response
|
* @param response
|
||||||
@ -151,5 +151,5 @@ public class WxWorkFilter implements Filter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,8 +11,10 @@ import com.nbclass.util.MyMapper;
|
|||||||
public interface ListTypeMapper extends MyMapper<ListType> {
|
public interface ListTypeMapper extends MyMapper<ListType> {
|
||||||
|
|
||||||
public List<ListType> getList(@Param("listType")String listType);
|
public List<ListType> getList(@Param("listType")String listType);
|
||||||
|
|
||||||
public String getListValue(@Param("listType")String listType,@Param("id")String id);
|
public String getListValue(@Param("listType")String listType,@Param("id")String id);
|
||||||
|
|
||||||
public String getAreaIdByName(@Param("areaName")String areaName);
|
public String getAreaIdByName(@Param("areaName")String areaName);
|
||||||
}
|
|
||||||
|
List<ListType> getComboBox();
|
||||||
|
}
|
||||||
|
|||||||
@ -0,0 +1,11 @@
|
|||||||
|
package com.nbclass.szxgl.mapper;
|
||||||
|
|
||||||
|
import com.nbclass.szxgl.model.ProjectTaskTerm;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ProjectTaskTermMapper {
|
||||||
|
|
||||||
|
void addProjectTaskTerm(ProjectTaskTerm projectTaskTerm);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package com.nbclass.szxgl.mapper2;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface DataDictItemMapper {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据参数模糊匹配标签
|
||||||
|
* @param tagNames
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Map<String,Object>> getTagNames(String tagNames);
|
||||||
|
|
||||||
|
}
|
||||||
13
src/main/java/com/nbclass/szxgl/mapper2/TestMapper.java
Normal file
13
src/main/java/com/nbclass/szxgl/mapper2/TestMapper.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package com.nbclass.szxgl.mapper2;
|
||||||
|
|
||||||
|
import com.nbclass.szxgl.model.Content;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface TestMapper {
|
||||||
|
|
||||||
|
List<Content> getContent();
|
||||||
|
|
||||||
|
}
|
||||||
30
src/main/java/com/nbclass/szxgl/model/Content.java
Normal file
30
src/main/java/com/nbclass/szxgl/model/Content.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package com.nbclass.szxgl.model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Table(name = "content")
|
||||||
|
public class Content implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -6422276602170816740L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID, 主键,自增
|
||||||
|
*/
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
}
|
||||||
@ -3,10 +3,11 @@ package com.nbclass.szxgl.model;
|
|||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Table(name = "list_values")
|
@Table(name = "list_values")
|
||||||
public class ListType {
|
public class ListType {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
@ -16,7 +17,9 @@ public class ListType {
|
|||||||
@Column(name = "list_type")
|
@Column(name = "list_type")
|
||||||
private String listType;
|
private String listType;
|
||||||
|
|
||||||
/**
|
private List<ListType> listTypes;
|
||||||
|
|
||||||
|
/**
|
||||||
* 名称
|
* 名称
|
||||||
*/
|
*/
|
||||||
@Column(name = "list_value")
|
@Column(name = "list_value")
|
||||||
@ -46,11 +49,12 @@ public class ListType {
|
|||||||
this.listValue = listValue;
|
this.listValue = listValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ListType> getListTypes() {
|
||||||
|
return listTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setListTypes(List<ListType> listTypes) {
|
||||||
|
this.listTypes = listTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@ -48,6 +48,12 @@ public class ProjectTaskJournal {
|
|||||||
@Column(name = "_create_user_id")
|
@Column(name = "_create_user_id")
|
||||||
private String createUserId;
|
private String createUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*素材是否有侵权风险(1、无风险 2、有风险)
|
||||||
|
*/
|
||||||
|
@Column(name = "_risk")
|
||||||
|
private Integer risk;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
@ -60,16 +66,16 @@ public class ProjectTaskJournal {
|
|||||||
@Column(name = "_update_time")
|
@Column(name = "_update_time")
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
|
|
||||||
// 以下是查询字段
|
// 以下是查询字段
|
||||||
/**
|
/**
|
||||||
* 创建人姓名
|
* 创建人姓名
|
||||||
*/
|
*/
|
||||||
@Transient
|
@Transient
|
||||||
private String createUserName;
|
private String createUserName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return id
|
* @return id
|
||||||
*/
|
*/
|
||||||
@ -235,6 +241,12 @@ public class ProjectTaskJournal {
|
|||||||
public void setCreateUserName(String createUserName) {
|
public void setCreateUserName(String createUserName) {
|
||||||
this.createUserName = createUserName;
|
this.createUserName = createUserName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getRisk() {
|
||||||
}
|
return risk;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRisk(Integer risk) {
|
||||||
|
this.risk = risk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
25
src/main/java/com/nbclass/szxgl/model/ProjectTaskTerm.java
Normal file
25
src/main/java/com/nbclass/szxgl/model/ProjectTaskTerm.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package com.nbclass.szxgl.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ProjectTaskTerm {
|
||||||
|
|
||||||
|
private String id ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目id
|
||||||
|
*/
|
||||||
|
private String projectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典值id
|
||||||
|
*/
|
||||||
|
private String listValuesId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工期(天)
|
||||||
|
*/
|
||||||
|
private Integer term;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.nbclass.szxgl.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ES搜索
|
||||||
|
* @author Leon
|
||||||
|
* @datetime 2020年6月1日 下午3:00:41
|
||||||
|
*/
|
||||||
|
public interface ElasticSearchService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据条件查询列表
|
||||||
|
* @param pageNum
|
||||||
|
* @param pageSize
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getList(String tagIds,String caseName,Integer pageNum, Integer pageSize);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -27,7 +27,7 @@ public interface ProjectTaskService {
|
|||||||
* @param userIds
|
* @param userIds
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public void addProjectTask(ProjectTask t, Integer isSendMsg, String[] userIds);
|
public void addProjectTask(ProjectTask t, Integer isSendMsg, String[] userIds,String listValues);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改项目任务
|
* 修改项目任务
|
||||||
|
|||||||
@ -3,16 +3,18 @@ package com.nbclass.szxgl.service;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.nbclass.system.model.User;
|
||||||
import com.nbclass.szxgl.model.SyUsers;
|
import com.nbclass.szxgl.model.SyUsers;
|
||||||
|
|
||||||
public interface SyUsersService {
|
public interface SyUsersService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户id查询
|
* 根据用户id查询
|
||||||
* @param username
|
* @param username
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public SyUsers selectByUsername(String username);
|
public SyUsers selectByUsername(String username);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
11
src/main/java/com/nbclass/szxgl/service/TestService.java
Normal file
11
src/main/java/com/nbclass/szxgl/service/TestService.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package com.nbclass.szxgl.service;
|
||||||
|
|
||||||
|
import com.nbclass.szxgl.model.Content;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface TestService {
|
||||||
|
|
||||||
|
List<Content> getContent();
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,99 @@
|
|||||||
|
package com.nbclass.szxgl.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.nbclass.szxgl.model.Content;
|
||||||
|
import com.nbclass.szxgl.service.ElasticSearchService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.elasticsearch.action.search.SearchRequest;
|
||||||
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
|
import org.elasticsearch.client.RequestOptions;
|
||||||
|
import org.elasticsearch.client.RestHighLevelClient;
|
||||||
|
import org.elasticsearch.index.query.*;
|
||||||
|
import org.elasticsearch.search.SearchHit;
|
||||||
|
import org.elasticsearch.search.SearchHits;
|
||||||
|
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||||
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class ElasticSearchServiceImpl implements ElasticSearchService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RestHighLevelClient restHighLevelClient;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getList(String tagIds,String caseName,Integer pageNum, Integer pageSize) {
|
||||||
|
// 封装Map参数返回
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
try {
|
||||||
|
// 选择标签或来源过滤时,从数据库查询记录
|
||||||
|
/*if(StringUtils.isNotBlank(tagIds) || StringUtils.isNotBlank(sourceIds)) {
|
||||||
|
return getListByMySQL(pageNum, pageSize, type, keyWord, tagIds, sourceIds);
|
||||||
|
}*/
|
||||||
|
if(StringUtils.isNoneBlank(tagIds) || StringUtils.isNoneBlank(caseName)){
|
||||||
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
||||||
|
// 分页采用简单的from + size分页,适用数据量小的,了解更多分页方式可自行查阅资料
|
||||||
|
searchSourceBuilder.from((pageNum - 1) * pageSize); // 从0开始
|
||||||
|
searchSourceBuilder.size(pageSize);
|
||||||
|
|
||||||
|
|
||||||
|
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||||
|
boolQueryBuilder.must(QueryBuilders.termQuery("release", 2));
|
||||||
|
|
||||||
|
|
||||||
|
// if(StringUtils.isNoneBlank(tagIds) && StringUtils.isNoneBlank(caseName)){
|
||||||
|
// boolQueryBuilder.must(QueryBuilders.termQuery("release", 2));
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (StringUtils.isNoneBlank(tagIds)){
|
||||||
|
List<String> list = Arrays.asList(tagIds.split(","));
|
||||||
|
for(String tagId:list) {
|
||||||
|
boolQueryBuilder.must(QueryBuilders.termQuery("tagList.tid", tagId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(StringUtils.isNoneBlank(caseName)){
|
||||||
|
BoolQueryBuilder keywordQuery = QueryBuilders.boolQuery();
|
||||||
|
keywordQuery.must(QueryBuilders.matchQuery("title", caseName)).boost(2F);
|
||||||
|
boolQueryBuilder.should(keywordQuery);
|
||||||
|
}else {
|
||||||
|
// 排序,根据点赞数倒叙
|
||||||
|
searchSourceBuilder.sort("praiseno", SortOrder.DESC);
|
||||||
|
}
|
||||||
|
|
||||||
|
searchSourceBuilder.query(boolQueryBuilder);
|
||||||
|
|
||||||
|
// SearchRequest
|
||||||
|
SearchRequest searchRequest = new SearchRequest();
|
||||||
|
searchRequest.source(searchSourceBuilder);
|
||||||
|
// 查询ES
|
||||||
|
SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
|
||||||
|
SearchHits hits = searchResponse.getHits();
|
||||||
|
// 获取总数
|
||||||
|
Long total = hits.getTotalHits().value;
|
||||||
|
// 遍历封装列表对象
|
||||||
|
List<Content> dataList = new ArrayList<>();
|
||||||
|
SearchHit[] searchHits = hits.getHits();
|
||||||
|
for (SearchHit searchHit : searchHits) {
|
||||||
|
Content entity = JSON.parseObject(searchHit.getSourceAsString(), Content.class);
|
||||||
|
dataList.add(entity);
|
||||||
|
System.out.println(searchHit.getSourceAsString());
|
||||||
|
}
|
||||||
|
result.put("total", total); // 总记录数
|
||||||
|
result.put("rows", dataList); // 数据体
|
||||||
|
int totalPage = (int)(total % pageSize==0 ? total/pageSize : total/pageSize+1);
|
||||||
|
result.put("totalPage", totalPage); // 总页数
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (Exception e) {
|
||||||
|
log.error("从es查询数据列表异常", e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,7 @@
|
|||||||
package com.nbclass.szxgl.service.impl;
|
package com.nbclass.szxgl.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.nbclass.exception.ParameterException;
|
import com.nbclass.exception.ParameterException;
|
||||||
import com.nbclass.exception.ServiceException;
|
import com.nbclass.exception.ServiceException;
|
||||||
import com.nbclass.system.model.User;
|
import com.nbclass.system.model.User;
|
||||||
@ -48,6 +50,9 @@ public class ProjectTaskServiceImpl implements ProjectTaskService {
|
|||||||
@Resource
|
@Resource
|
||||||
ProjectService projectService;
|
ProjectService projectService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ProjectTaskTermMapper projectTaskTermMapper;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean deleteProjectTask(String projectId, String[] ids) {
|
public boolean deleteProjectTask(String projectId, String[] ids) {
|
||||||
@ -79,7 +84,7 @@ public class ProjectTaskServiceImpl implements ProjectTaskService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void addProjectTask(ProjectTask t, Integer isSendMsg, String[] userIds) {
|
public void addProjectTask(ProjectTask t, Integer isSendMsg, String[] userIds,String listValues) {
|
||||||
if(t.getStartTime().getTime() > t.getEndTime().getTime()) {
|
if(t.getStartTime().getTime() > t.getEndTime().getTime()) {
|
||||||
throw new ParameterException("项目任务时间范围不对!");
|
throw new ParameterException("项目任务时间范围不对!");
|
||||||
}
|
}
|
||||||
@ -98,6 +103,16 @@ public class ProjectTaskServiceImpl implements ProjectTaskService {
|
|||||||
t.setNotify((short) 0);//默认0,生产环境改为1
|
t.setNotify((short) 0);//默认0,生产环境改为1
|
||||||
projectTaskMapper.insert(t);
|
projectTaskMapper.insert(t);
|
||||||
|
|
||||||
|
JSONArray jsonArray = JSONObject.parseArray(listValues);
|
||||||
|
for (int i = 0; i < jsonArray.size(); i++) {
|
||||||
|
//添加工期信息
|
||||||
|
ProjectTaskTerm projectTaskTerm = jsonArray.getObject(i, ProjectTaskTerm.class);
|
||||||
|
projectTaskTerm.setProjectId(t.getId());
|
||||||
|
projectTaskTerm.setId(UUIDUtil.uuid());
|
||||||
|
projectTaskTermMapper.addProjectTaskTerm(projectTaskTerm);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 等待保存的对象集合
|
// 等待保存的对象集合
|
||||||
List<ProjectTaskUser> c = new ArrayList<ProjectTaskUser>();
|
List<ProjectTaskUser> c = new ArrayList<ProjectTaskUser>();
|
||||||
Set<String> sendIds = new HashSet<String>();// 需要发送消息提醒的用户
|
Set<String> sendIds = new HashSet<String>();// 需要发送消息提醒的用户
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.nbclass.szxgl.service.impl;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import com.nbclass.system.model.User;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.nbclass.szxgl.mapper.QywxUserMapper;
|
import com.nbclass.szxgl.mapper.QywxUserMapper;
|
||||||
@ -11,7 +12,7 @@ import com.nbclass.szxgl.service.SyUsersService;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SyUsersServiceImpl implements SyUsersService {
|
public class SyUsersServiceImpl implements SyUsersService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SyUsersMapper mapper;
|
private SyUsersMapper mapper;
|
||||||
@Resource
|
@Resource
|
||||||
@ -25,6 +26,4 @@ public class SyUsersServiceImpl implements SyUsersService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.nbclass.szxgl.service.impl;
|
||||||
|
|
||||||
|
import com.nbclass.szxgl.mapper2.TestMapper;
|
||||||
|
import com.nbclass.szxgl.model.Content;
|
||||||
|
import com.nbclass.szxgl.service.TestService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TestServiceImpl implements TestService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TestMapper testMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Content> getContent() {
|
||||||
|
return testMapper.getContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.nbclass.util;
|
package com.nbclass.util;
|
||||||
|
|
||||||
|
import com.nbclass.system.model.User;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
|
||||||
@ -53,7 +55,7 @@ import java.security.SecureRandom;
|
|||||||
* String stronger_salt = BCrypt.gensalt(12)<br />
|
* String stronger_salt = BCrypt.gensalt(12)<br />
|
||||||
* </code>
|
* </code>
|
||||||
* <p>
|
* <p>
|
||||||
* The amount of work increases exponentially (2**log_rounds), so
|
* The amount of work increases exponentially (2**log_rounds), so
|
||||||
* each increment is twice as much work. The default log_rounds is
|
* each increment is twice as much work. The default log_rounds is
|
||||||
* 10, and the valid range is 4 to 30.
|
* 10, and the valid range is 4 to 30.
|
||||||
*
|
*
|
||||||
@ -774,4 +776,5 @@ public class BCrypt {
|
|||||||
ret |= hashed_bytes[i] ^ try_bytes[i];
|
ret |= hashed_bytes[i] ^ try_bytes[i];
|
||||||
return ret == 0;
|
return ret == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,19 +1,25 @@
|
|||||||
package com.nbclass.util;
|
package com.nbclass.util;
|
||||||
|
|
||||||
|
import org.apache.shiro.codec.Base64;
|
||||||
|
import org.apache.shiro.codec.Hex;
|
||||||
|
import org.apache.shiro.crypto.AesCipherService;
|
||||||
import org.apache.shiro.crypto.RandomNumberGenerator;
|
import org.apache.shiro.crypto.RandomNumberGenerator;
|
||||||
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
|
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
|
||||||
|
import org.apache.shiro.crypto.hash.Md5Hash;
|
||||||
import org.apache.shiro.crypto.hash.SimpleHash;
|
import org.apache.shiro.crypto.hash.SimpleHash;
|
||||||
import org.apache.shiro.util.ByteSource;
|
import org.apache.shiro.util.ByteSource;
|
||||||
|
|
||||||
import com.nbclass.system.model.User;
|
import com.nbclass.system.model.User;
|
||||||
|
|
||||||
|
import java.security.Key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 密码加密
|
* 密码加密
|
||||||
* @author Leon
|
* @author Leon
|
||||||
* @datetime 2019年4月1日 下午10:09:02
|
* @datetime 2019年4月1日 下午10:09:02
|
||||||
*/
|
*/
|
||||||
public class PasswordHelper {
|
public class PasswordHelper {
|
||||||
|
|
||||||
private static RandomNumberGenerator randomNumberGenerator = new SecureRandomNumberGenerator();
|
private static RandomNumberGenerator randomNumberGenerator = new SecureRandomNumberGenerator();
|
||||||
private static String algorithmName = "md5";
|
private static String algorithmName = "md5";
|
||||||
private static int hashIterations = 2;
|
private static int hashIterations = 2;
|
||||||
@ -37,7 +43,7 @@ public class PasswordHelper {
|
|||||||
public static String encryptPwdByBCrypt(String password){
|
public static String encryptPwdByBCrypt(String password){
|
||||||
return BCrypt.hashpw(password, BCrypt.gensalt());
|
return BCrypt.hashpw(password, BCrypt.gensalt());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BCrypt 密码验证
|
* BCrypt 密码验证
|
||||||
* @param password 明文
|
* @param password 明文
|
||||||
@ -47,17 +53,26 @@ public class PasswordHelper {
|
|||||||
public static boolean checkPwdByBCrypt(String password, String ciphertext){
|
public static boolean checkPwdByBCrypt(String password, String ciphertext){
|
||||||
return BCrypt.checkpw(password, ciphertext);
|
return BCrypt.checkpw(password, ciphertext);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.setUsername("admin");
|
user.setUsername("admin");
|
||||||
user.setPassword("szxgl.com");
|
user.setPassword("szxgl.com");
|
||||||
encryptPassword(user);
|
encryptPassword(user);
|
||||||
|
|
||||||
System.out.println("salt="+user.getSalt());
|
System.out.println("salt="+user.getSalt());
|
||||||
System.out.println("password="+user.getPassword());
|
System.out.println("password="+user.getPassword());
|
||||||
|
|
||||||
String pwd1 = encryptPwdByBCrypt("123456");
|
String pwd1 = encryptPwdByBCrypt("123456");
|
||||||
boolean result = checkPwdByBCrypt("123456", pwd1);
|
boolean result = checkPwdByBCrypt("123456", pwd1);
|
||||||
System.out.println("pwd1="+pwd1+", result="+result);
|
System.out.println("pwd1="+pwd1+", result="+result);
|
||||||
|
|
||||||
|
String hashAlgorithmName = "MD5";//加密方式
|
||||||
|
Object crdentials = "123456";//密码原值
|
||||||
|
Object salt = null;//盐值
|
||||||
|
int hashIterations = 2;//加密1024次
|
||||||
|
Object result2 = new SimpleHash(hashAlgorithmName,crdentials,salt,hashIterations);
|
||||||
|
System.out.println(result2);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,23 +23,20 @@ import java.sql.PreparedStatement;
|
|||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.Vector;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.nbclass.szxgl.model.ProjectTaskTerm;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.apache.commons.codec.digest.UnixCrypt;
|
import org.apache.commons.codec.digest.UnixCrypt;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工具类
|
* 工具类
|
||||||
@ -49,9 +46,9 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
public class Utility implements java.io.Serializable {
|
public class Utility implements java.io.Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
protected static Utility instance = null;
|
protected static Utility instance = null;
|
||||||
|
|
||||||
public static synchronized void setInstance(boolean clear) {
|
public static synchronized void setInstance(boolean clear) {
|
||||||
if (clear)
|
if (clear)
|
||||||
instance = null;
|
instance = null;
|
||||||
@ -68,7 +65,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
protected Utility() {
|
protected Utility() {
|
||||||
instance = null;
|
instance = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert integer string array into integer array
|
* Convert integer string array into integer array
|
||||||
@ -102,7 +99,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int[] toIntArray(String str){
|
public static int[] toIntArray(String str){
|
||||||
if(str == null || str.equals("")) return null;
|
if(str == null || str.equals("")) return null;
|
||||||
int[] result;
|
int[] result;
|
||||||
@ -124,7 +121,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String encodeHTML(String value) {
|
public static String encodeHTML(String value) {
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return "";
|
return "";
|
||||||
@ -143,7 +140,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This function will convert the string to a unicode string. (e.g. "\u7f51")
|
* This function will convert the string to a unicode string. (e.g. "\u7f51")
|
||||||
*
|
*
|
||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -183,7 +180,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a instance from a class
|
* Create a instance from a class
|
||||||
*
|
*
|
||||||
* @param service
|
* @param service
|
||||||
* @return @throws
|
* @return @throws
|
||||||
* ClassNotFoundException
|
* ClassNotFoundException
|
||||||
@ -203,14 +200,14 @@ public class Utility implements java.io.Serializable {
|
|||||||
result = bd.setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
|
result = bd.setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getRoundUp(float d, int scale) {
|
public static float getRoundUp(float d, int scale) {
|
||||||
float result = d;
|
float result = d;
|
||||||
BigDecimal bd = new BigDecimal(d);
|
BigDecimal bd = new BigDecimal(d);
|
||||||
result = bd.setScale(scale, BigDecimal.ROUND_HALF_UP).floatValue();
|
result = bd.setScale(scale, BigDecimal.ROUND_HALF_UP).floatValue();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Calendar getCalendar(Date date) throws Exception {
|
public static Calendar getCalendar(Date date) throws Exception {
|
||||||
Calendar result = Calendar.getInstance();
|
Calendar result = Calendar.getInstance();
|
||||||
result.setTime(date);
|
result.setTime(date);
|
||||||
@ -222,10 +219,10 @@ public class Utility implements java.io.Serializable {
|
|||||||
result.setTimeInMillis(milliseconds);
|
result.setTimeInMillis(milliseconds);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTimeStampWithMillis() {
|
public static String getTimeStampWithMillis() {
|
||||||
return getTimeStampWithMillis(Calendar.getInstance());
|
return getTimeStampWithMillis(Calendar.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTimeStampWithMillis(Calendar calendar) {
|
public static String getTimeStampWithMillis(Calendar calendar) {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
||||||
@ -280,7 +277,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
SimpleDateFormat sdf = new SimpleDateFormat(format);
|
SimpleDateFormat sdf = new SimpleDateFormat(format);
|
||||||
return sdf.format(date.getTime());
|
return sdf.format(date.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getHttpContent(String urlStr, String encoding) throws Exception {
|
public static String getHttpContent(String urlStr, String encoding) throws Exception {
|
||||||
URL url = new URL(urlStr);
|
URL url = new URL(urlStr);
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
@ -323,7 +320,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
return bos.toByteArray();
|
return bos.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Object byteArrayToObject(byte[] array) throws Exception {
|
public static Object byteArrayToObject(byte[] array) throws Exception {
|
||||||
ByteArrayInputStream bis = new ByteArrayInputStream(array);
|
ByteArrayInputStream bis = new ByteArrayInputStream(array);
|
||||||
@ -371,24 +368,24 @@ public class Utility implements java.io.Serializable {
|
|||||||
public static String getFormatedTimeStamp() {
|
public static String getFormatedTimeStamp() {
|
||||||
return getFormatedTimeStamp(Calendar.getInstance());
|
return getFormatedTimeStamp(Calendar.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getFormatedTimeStamp(Calendar calendar) {
|
public static String getFormatedTimeStamp(Calendar calendar) {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
|
||||||
return sdf.format(calendar.getTime());
|
return sdf.format(calendar.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTimeStamp() {
|
public static String getTimeStamp() {
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
return getTimeStamp(calendar);
|
return getTimeStamp(calendar);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTimeStamp(Calendar calendar) {
|
public static String getTimeStamp(Calendar calendar) {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||||
String result = sdf.format(calendar.getTime());
|
String result = sdf.format(calendar.getTime());
|
||||||
result = result + "000";
|
result = result + "000";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String getFormatedFileSize(long value) {
|
public static String getFormatedFileSize(long value) {
|
||||||
double kb = value / 1024.00;
|
double kb = value / 1024.00;
|
||||||
@ -420,13 +417,13 @@ public class Utility implements java.io.Serializable {
|
|||||||
calendar.add(Calendar.DATE, -1);
|
calendar.add(Calendar.DATE, -1);
|
||||||
return calendar.getTime();
|
return calendar.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDateFormat(Date date, String format) {
|
public static String getDateFormat(Date date, String format) {
|
||||||
if (date == null) return "";
|
if (date == null) return "";
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat(format, Locale.US);
|
SimpleDateFormat dateFormat = new SimpleDateFormat(format, Locale.US);
|
||||||
return dateFormat.format(date);
|
return dateFormat.format(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static java.sql.Date UtilDateToSQLDate(Date utilDate) {
|
public static java.sql.Date UtilDateToSQLDate(Date utilDate) {
|
||||||
if (utilDate == null) return null;
|
if (utilDate == null) return null;
|
||||||
return new java.sql.Date(utilDate.getTime());
|
return new java.sql.Date(utilDate.getTime());
|
||||||
@ -441,19 +438,19 @@ public class Utility implements java.io.Serializable {
|
|||||||
if (SQLDate == null) return null;
|
if (SQLDate == null) return null;
|
||||||
return new Date(SQLDate.getTime());
|
return new Date(SQLDate.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static java.util.Date SQLDateToUtilDate(java.sql.Timestamp SQLDate) {
|
public static java.util.Date SQLDateToUtilDate(java.sql.Timestamp SQLDate) {
|
||||||
if (SQLDate == null) return null;
|
if (SQLDate == null) return null;
|
||||||
return new Date(SQLDate.getTime());
|
return new Date(SQLDate.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Date parseDate(String strDate, String pattern) throws Exception {
|
public static Date parseDate(String strDate, String pattern) throws Exception {
|
||||||
if (strDate == null || strDate.trim().equals("")) return null;
|
if (strDate == null || strDate.trim().equals("")) return null;
|
||||||
SimpleDateFormat format = new SimpleDateFormat(pattern);
|
SimpleDateFormat format = new SimpleDateFormat(pattern);
|
||||||
Date date = format.parse(strDate);
|
Date date = format.parse(strDate);
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getSearchFormat(String pattern) {
|
public static String getSearchFormat(String pattern) {
|
||||||
if (pattern == null) return "%";
|
if (pattern == null) return "%";
|
||||||
pattern = pattern.trim(); // format maybe : A, A%, %A%, A%B%, %A"B
|
pattern = pattern.trim(); // format maybe : A, A%, %A%, A%B%, %A"B
|
||||||
@ -464,7 +461,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
return pattern;
|
return pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getLeadingZero(int intValue, int maxLength) {
|
public static String getLeadingZero(int intValue, int maxLength) {
|
||||||
String result = String.valueOf(intValue);
|
String result = String.valueOf(intValue);
|
||||||
if (result.length() < maxLength) {
|
if (result.length() < maxLength) {
|
||||||
@ -474,17 +471,17 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getQuantityAsString(float qty) {
|
public static String getQuantityAsString(float qty) {
|
||||||
DecimalFormat df = new DecimalFormat("#0.00");
|
DecimalFormat df = new DecimalFormat("#0.00");
|
||||||
return df.format(qty);
|
return df.format(qty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getQuantityAsString(double qty) {
|
public static String getQuantityAsString(double qty) {
|
||||||
DecimalFormat df = new DecimalFormat("#0.00");
|
DecimalFormat df = new DecimalFormat("#0.00");
|
||||||
return df.format(qty);
|
return df.format(qty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getQuantityAsString(float amt, String pattern) {
|
public static String getQuantityAsString(float amt, String pattern) {
|
||||||
DecimalFormat df = new DecimalFormat(pattern);
|
DecimalFormat df = new DecimalFormat(pattern);
|
||||||
return df.format(amt);
|
return df.format(amt);
|
||||||
@ -504,17 +501,17 @@ public class Utility implements java.io.Serializable {
|
|||||||
DecimalFormat df = new DecimalFormat(pattern);
|
DecimalFormat df = new DecimalFormat(pattern);
|
||||||
return df.format(amt);
|
return df.format(amt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getAmountAsString(double amt, String pattern) {
|
public static String getAmountAsString(double amt, String pattern) {
|
||||||
DecimalFormat df = new DecimalFormat(pattern);
|
DecimalFormat df = new DecimalFormat(pattern);
|
||||||
return df.format(amt);
|
return df.format(amt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getFloatFormat(float f, String pattern) {
|
public static String getFloatFormat(float f, String pattern) {
|
||||||
DecimalFormat df = new DecimalFormat(pattern);
|
DecimalFormat df = new DecimalFormat(pattern);
|
||||||
return df.format(f);
|
return df.format(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDoubleFormat(double d, String pattern) {
|
public static String getDoubleFormat(double d, String pattern) {
|
||||||
DecimalFormat df = new DecimalFormat(pattern);
|
DecimalFormat df = new DecimalFormat(pattern);
|
||||||
return df.format(d);
|
return df.format(d);
|
||||||
@ -530,30 +527,30 @@ public class Utility implements java.io.Serializable {
|
|||||||
public static double mul(double d1, double d2) {
|
public static double mul(double d1, double d2) {
|
||||||
BigDecimal b1 = new BigDecimal(String.valueOf(d1));
|
BigDecimal b1 = new BigDecimal(String.valueOf(d1));
|
||||||
BigDecimal b2 = new BigDecimal(String.valueOf(d2));
|
BigDecimal b2 = new BigDecimal(String.valueOf(d2));
|
||||||
|
|
||||||
return b1.multiply(b2).doubleValue();
|
return b1.multiply(b2).doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double mul(BigDecimal b1, double d2) {
|
public static double mul(BigDecimal b1, double d2) {
|
||||||
BigDecimal b2 = new BigDecimal(String.valueOf(d2));
|
BigDecimal b2 = new BigDecimal(String.valueOf(d2));
|
||||||
|
|
||||||
return b1.multiply(b2).doubleValue();
|
return b1.multiply(b2).doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double add(double d1, double d2) {
|
public static double add(double d1, double d2) {
|
||||||
BigDecimal b1 = new BigDecimal(String.valueOf(d1));
|
BigDecimal b1 = new BigDecimal(String.valueOf(d1));
|
||||||
BigDecimal b2 = new BigDecimal(String.valueOf(d2));
|
BigDecimal b2 = new BigDecimal(String.valueOf(d2));
|
||||||
|
|
||||||
return b1.add(b2).doubleValue();
|
return b1.add(b2).doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPositiveInteger(String inValue) {
|
public static boolean isPositiveInteger(String inValue) {
|
||||||
return isNumericValue(inValue, false, false);
|
return isNumericValue(inValue, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isNumericValue(String inValue) {
|
public static boolean isNumericValue(String inValue) {
|
||||||
return isNumericValue(inValue, true, true);
|
return isNumericValue(inValue, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isNumericValue(String inValue, boolean includeSymbol, boolean includeDecimal) {
|
public static boolean isNumericValue(String inValue, boolean includeSymbol, boolean includeDecimal) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
@ -578,7 +575,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getIDAsString(ArrayList<?> idList, int idFrom, int idTo) {
|
public static String getIDAsString(ArrayList<?> idList, int idFrom, int idTo) {
|
||||||
String IDs = null;
|
String IDs = null;
|
||||||
if (idList != null && idList.size() > 0) {
|
if (idList != null && idList.size() > 0) {
|
||||||
@ -587,7 +584,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
int lp;
|
int lp;
|
||||||
IDs = idList.get(idFrom).toString();
|
IDs = idList.get(idFrom).toString();
|
||||||
if (idList.size() > 1 && idTo > idFrom) {
|
if (idList.size() > 1 && idTo > idFrom) {
|
||||||
for (lp = idFrom+1; lp < idTo; lp ++) IDs += "," + idList.get(lp).toString();
|
for (lp = idFrom+1; lp < idTo; lp ++) IDs += "," + idList.get(lp).toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return IDs;
|
return IDs;
|
||||||
@ -601,15 +598,15 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPreparedParameterList(PreparedStatement stmt, int startParamIndex, ArrayList<Integer> idList, int fromID, int toID) throws Exception {
|
public static void setPreparedParameterList(PreparedStatement stmt, int startParamIndex, ArrayList<Integer> idList, int fromID, int toID) throws Exception {
|
||||||
int idx = startParamIndex;
|
int idx = startParamIndex;
|
||||||
for (int i = fromID; i <= toID; i++) {
|
for (int i = fromID; i <= toID; i++) {
|
||||||
stmt.setInt(idx, idList.get(i).intValue());
|
stmt.setInt(idx, idList.get(i).intValue());
|
||||||
idx ++;
|
idx ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String replaceMailAddress(String mailAddress, String oldPattern, String newPattern) {
|
public static String replaceMailAddress(String mailAddress, String oldPattern, String newPattern) {
|
||||||
if (mailAddress == null || mailAddress.trim().equals("") || oldPattern == null || newPattern == null)
|
if (mailAddress == null || mailAddress.trim().equals("") || oldPattern == null || newPattern == null)
|
||||||
return mailAddress;
|
return mailAddress;
|
||||||
@ -617,19 +614,19 @@ public class Utility implements java.io.Serializable {
|
|||||||
return mailAddress.trim().replaceAll(oldPattern, newPattern);
|
return mailAddress.trim().replaceAll(oldPattern, newPattern);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getValidMailAddress(String mailAddress, String defaultAddress) {
|
public static String getValidMailAddress(String mailAddress, String defaultAddress) {
|
||||||
if (mailAddress != null && !mailAddress.trim().equals(""))
|
if (mailAddress != null && !mailAddress.trim().equals(""))
|
||||||
return mailAddress;
|
return mailAddress;
|
||||||
else
|
else
|
||||||
return defaultAddress;
|
return defaultAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getValidString(String str) {
|
public static String getValidString(String str) {
|
||||||
if (str == null) return "";
|
if (str == null) return "";
|
||||||
else return str;
|
else return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getMailTo(String to) {
|
public static String[] getMailTo(String to) {
|
||||||
String[] toAC = null;
|
String[] toAC = null;
|
||||||
if (to != null && to.indexOf("@") != -1) {
|
if (to != null && to.indexOf("@") != -1) {
|
||||||
@ -643,15 +640,15 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
return toAC;
|
return toAC;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getASCII(String str) {
|
public static int getASCII(String str) {
|
||||||
int result = 48;
|
int result = 48;
|
||||||
if (str != null && !str.trim().equals("")) {
|
if (str != null && !str.trim().equals("")) {
|
||||||
result = 48 + Integer.parseInt(str);
|
result = 48 + Integer.parseInt(str);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getKeyAsVector(String s_key, Vector<String> v_key) {
|
public static void getKeyAsVector(String s_key, Vector<String> v_key) {
|
||||||
int idx;
|
int idx;
|
||||||
if (s_key != null && !s_key.trim().equals("")) {
|
if (s_key != null && !s_key.trim().equals("")) {
|
||||||
@ -660,7 +657,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
idx = s_key.indexOf(".");
|
idx = s_key.indexOf(".");
|
||||||
if (idx != -1) {
|
if (idx != -1) {
|
||||||
v_key.addElement(s_key.substring(0, idx));
|
v_key.addElement(s_key.substring(0, idx));
|
||||||
s_key = s_key.substring(idx+1);
|
s_key = s_key.substring(idx+1);
|
||||||
} else {
|
} else {
|
||||||
v_key.addElement(s_key);
|
v_key.addElement(s_key);
|
||||||
s_key = "";
|
s_key = "";
|
||||||
@ -668,7 +665,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getNameFromAscII(String s_key, int startIndex, int length) {
|
public static String getNameFromAscII(String s_key, int startIndex, int length) {
|
||||||
Vector<String> v_key = new Vector<String>();
|
Vector<String> v_key = new Vector<String>();
|
||||||
Utility.getKeyAsVector(s_key, v_key);
|
Utility.getKeyAsVector(s_key, v_key);
|
||||||
@ -676,7 +673,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
v_key = null;
|
v_key = null;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getNameFromAscII(Vector<String> v_key, int startIndex, int length) {
|
public static String getNameFromAscII(Vector<String> v_key, int startIndex, int length) {
|
||||||
String result = "";
|
String result = "";
|
||||||
if (length > v_key.size() - startIndex) length = v_key.size() - startIndex;
|
if (length > v_key.size() - startIndex) length = v_key.size() - startIndex;
|
||||||
@ -685,7 +682,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String NameToASCII(String str) {
|
public static String NameToASCII(String str) {
|
||||||
String result = null;
|
String result = null;
|
||||||
char[] ch = str.toCharArray();
|
char[] ch = str.toCharArray();
|
||||||
@ -695,21 +692,21 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeLog(String log) {
|
public static void writeLog(String log) {
|
||||||
try {
|
try {
|
||||||
System.out.println(getFormatedTimeStamp() + " : " + log);
|
System.out.println(getFormatedTimeStamp() + " : " + log);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String intToHex(int i) {
|
public static String intToHex(int i) {
|
||||||
String result = Integer.toHexString(i).trim();
|
String result = Integer.toHexString(i).trim();
|
||||||
if (result.length() == 0) result = "00";
|
if (result.length() == 0) result = "00";
|
||||||
if (result.length() == 1) result = "0" + result;
|
if (result.length() == 1) result = "0" + result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int HexToInt(String s) {
|
public static int HexToInt(String s) {
|
||||||
return Integer.parseInt(Integer.valueOf(s, 16).toString());
|
return Integer.parseInt(Integer.valueOf(s, 16).toString());
|
||||||
}
|
}
|
||||||
@ -728,8 +725,8 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String getDateFormat(Calendar calendar){
|
public static String getDateFormat(Calendar calendar){
|
||||||
String returnValue="";
|
String returnValue="";
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
@ -738,7 +735,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
long hour=(leftTime/(60*60*1000)-day*24);
|
long hour=(leftTime/(60*60*1000)-day*24);
|
||||||
long min=((leftTime/(60*1000))-day*24*60-hour*60);
|
long min=((leftTime/(60*1000))-day*24*60-hour*60);
|
||||||
long s=(leftTime/1000-day*24*60*60-hour*60*60-min*60);
|
long s=(leftTime/1000-day*24*60*60-hour*60*60-min*60);
|
||||||
|
|
||||||
if(returnValue.equals("") && day>=365){
|
if(returnValue.equals("") && day>=365){
|
||||||
int year = (int) (day/365);
|
int year = (int) (day/365);
|
||||||
returnValue=year+"年前";
|
returnValue=year+"年前";
|
||||||
@ -757,14 +754,14 @@ public class Utility implements java.io.Serializable {
|
|||||||
returnValue=s+"秒前";
|
returnValue=s+"秒前";
|
||||||
if(returnValue.equals(""))
|
if(returnValue.equals(""))
|
||||||
returnValue="0秒前";
|
returnValue="0秒前";
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getUUID(){
|
public static String getUUID(){
|
||||||
return java.util.UUID.randomUUID().toString();
|
return java.util.UUID.randomUUID().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 格式化日期 eg. 2014年07月10日 12:29 星期四
|
* 格式化日期 eg. 2014年07月10日 12:29 星期四
|
||||||
* @param date
|
* @param date
|
||||||
@ -773,9 +770,9 @@ public class Utility implements java.io.Serializable {
|
|||||||
public static String getDateCN(Date date){
|
public static String getDateCN(Date date){
|
||||||
SimpleDateFormat dateFm = new SimpleDateFormat("yyyy年MM月dd日 HH:mm EEEE");
|
SimpleDateFormat dateFm = new SimpleDateFormat("yyyy年MM月dd日 HH:mm EEEE");
|
||||||
return dateFm.format(date);
|
return dateFm.format(date);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件的后缀名
|
* 获取文件的后缀名
|
||||||
* @param filename
|
* @param filename
|
||||||
@ -786,12 +783,12 @@ public class Utility implements java.io.Serializable {
|
|||||||
if(filename!=null && filename.indexOf(".")!=-1)suffix=filename.substring(filename.lastIndexOf("."));
|
if(filename!=null && filename.indexOf(".")!=-1)suffix=filename.substring(filename.lastIndexOf("."));
|
||||||
return suffix;
|
return suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getFileSuffix(File file){
|
public static String getFileSuffix(File file){
|
||||||
String fileName=file.getName();
|
String fileName=file.getName();
|
||||||
return getFileSuffix(fileName);
|
return getFileSuffix(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取访问者IP
|
* 获取访问者IP
|
||||||
* 在一般情况下使用Request.getRemoteAddr()即可,但是经过nginx等反向代理软件后,这个方法会失效。
|
* 在一般情况下使用Request.getRemoteAddr()即可,但是经过nginx等反向代理软件后,这个方法会失效。
|
||||||
@ -810,20 +807,20 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||||
ip = request.getHeader("PRoxy-Client-IP");
|
ip = request.getHeader("PRoxy-Client-IP");
|
||||||
}
|
}
|
||||||
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||||
}
|
}
|
||||||
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||||
ip = request.getHeader("X-Real-IP");
|
ip = request.getHeader("X-Real-IP");
|
||||||
}
|
}
|
||||||
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||||
ip = request.getRemoteAddr();
|
ip = request.getRemoteAddr();
|
||||||
}
|
}
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String listToString(List<?> stringList){
|
public static String listToString(List<?> stringList){
|
||||||
if (stringList==null) {
|
if (stringList==null) {
|
||||||
return null;
|
return null;
|
||||||
@ -840,8 +837,8 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean strIsEqual(String str1, String str2){
|
public static boolean strIsEqual(String str1, String str2){
|
||||||
if(StringUtils.isBlank(str1) || StringUtils.isBlank(str2))return false;
|
if(StringUtils.isBlank(str1) || StringUtils.isBlank(str2))return false;
|
||||||
if(str1.equals(str2) || str1.trim().equals(str2.trim()))return true;
|
if(str1.equals(str2) || str1.trim().equals(str2.trim()))return true;
|
||||||
@ -862,7 +859,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断是否是浮点数
|
* 判断是否是浮点数
|
||||||
* @param str
|
* @param str
|
||||||
@ -876,8 +873,8 @@ public class Utility implements java.io.Serializable {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 密码加密方法
|
* 密码加密方法
|
||||||
* @param pwd
|
* @param pwd
|
||||||
@ -887,7 +884,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
if(StringUtils.isEmpty(pwd))return null;
|
if(StringUtils.isEmpty(pwd))return null;
|
||||||
else return UnixCrypt.crypt(pwd, DigestUtils.sha256Hex(pwd));
|
else return UnixCrypt.crypt(pwd, DigestUtils.sha256Hex(pwd));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 优惠码的生成, 默认6为长度
|
* 优惠码的生成, 默认6为长度
|
||||||
* @return
|
* @return
|
||||||
@ -895,7 +892,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
public static String getCode() {
|
public static String getCode() {
|
||||||
return getCode(6);
|
return getCode(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 优惠码的生成
|
* 优惠码的生成
|
||||||
* @return
|
* @return
|
||||||
@ -912,7 +909,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
final String code = new String(value);
|
final String code = new String(value);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过正则验证手机号码是否正确
|
* 通过正则验证手机号码是否正确
|
||||||
* @param str
|
* @param str
|
||||||
@ -925,7 +922,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
b = m.matches();
|
b = m.matches();
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 使用urlencode对链接进行编码
|
* 使用urlencode对链接进行编码
|
||||||
* @param url
|
* @param url
|
||||||
@ -959,7 +956,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
public static boolean isEmpty(String str){
|
public static boolean isEmpty(String str){
|
||||||
return (str == null || "".equals(str.trim()));
|
return (str == null || "".equals(str.trim()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isNotEmpty(String str){
|
public static boolean isNotEmpty(String str){
|
||||||
return (str != null && str.trim().length() > 0);
|
return (str != null && str.trim().length() > 0);
|
||||||
}
|
}
|
||||||
@ -980,7 +977,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断输入流是否是图片
|
* 判断输入流是否是图片
|
||||||
* @param inputStream
|
* @param inputStream
|
||||||
@ -999,7 +996,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过文件路径获取文件的ContentType
|
* 通过文件路径获取文件的ContentType
|
||||||
* JDK1.7以上支持
|
* JDK1.7以上支持
|
||||||
@ -1015,7 +1012,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
return contentType;
|
return contentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getReqIpAddr(HttpServletRequest request) {
|
public static String getReqIpAddr(HttpServletRequest request) {
|
||||||
String ip = null;
|
String ip = null;
|
||||||
try {
|
try {
|
||||||
@ -1035,10 +1032,10 @@ public class Utility implements java.io.Serializable {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取http访问路径,包括ContextPath
|
* 获取http访问路径,包括ContextPath
|
||||||
* @param request
|
* @param request
|
||||||
@ -1053,15 +1050,15 @@ public class Utility implements java.io.Serializable {
|
|||||||
String domainPath = request.getScheme()+"://"+request.getServerName()+strport+request.getContextPath();
|
String domainPath = request.getScheme()+"://"+request.getServerName()+strport+request.getContextPath();
|
||||||
return domainPath;
|
return domainPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成微信支付需要的nonce_str参数
|
* 生成微信支付需要的nonce_str参数
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String getNonceStr(){
|
public static String getNonceStr(){
|
||||||
return UUID.randomUUID().toString().replace("-", "");
|
return UUID.randomUUID().toString().replace("-", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成[min,max]区间的随机小数 (保留2位小数)
|
* 生成[min,max]区间的随机小数 (保留2位小数)
|
||||||
* @param min
|
* @param min
|
||||||
@ -1071,7 +1068,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
public static double getRandom(double min, double max){
|
public static double getRandom(double min, double max){
|
||||||
return getRandom(min, max, 2);
|
return getRandom(min, max, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成[min,max]区间的随机小数
|
* 生成[min,max]区间的随机小数
|
||||||
* @param min
|
* @param min
|
||||||
@ -1085,18 +1082,18 @@ public class Utility implements java.io.Serializable {
|
|||||||
result = round(result, scale); // 精度位数(保留的小数位数)
|
result = round(result, scale); // 精度位数(保留的小数位数)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double round(double value, int scale) {
|
private static double round(double value, int scale) {
|
||||||
return round(value, scale, BigDecimal.ROUND_HALF_UP);
|
return round(value, scale, BigDecimal.ROUND_HALF_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对double数据进行取精度.
|
* 对double数据进行取精度.
|
||||||
* @param value double数据.
|
* @param value double数据.
|
||||||
* @param scale 精度位数(保留的小数位数).
|
* @param scale 精度位数(保留的小数位数).
|
||||||
* @param roundingMode 精度取值方式.
|
* @param roundingMode 精度取值方式.
|
||||||
* @return 精度计算后的数据.
|
* @return 精度计算后的数据.
|
||||||
*/
|
*/
|
||||||
private static double round(double value, int scale, int roundingMode) {
|
private static double round(double value, int scale, int roundingMode) {
|
||||||
BigDecimal bd = new BigDecimal(value);
|
BigDecimal bd = new BigDecimal(value);
|
||||||
bd = bd.setScale(scale, roundingMode);
|
bd = bd.setScale(scale, roundingMode);
|
||||||
@ -1104,7 +1101,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
bd = null;
|
bd = null;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* double保留2位小数
|
* double保留2位小数
|
||||||
* @param value
|
* @param value
|
||||||
@ -1117,7 +1114,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
bd = null;
|
bd = null;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 向URL中添加参数(有则修改,无则添加)
|
* 向URL中添加参数(有则修改,无则添加)
|
||||||
* @param url
|
* @param url
|
||||||
@ -1139,7 +1136,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 替换URL参数的值
|
* 替换URL参数的值
|
||||||
* @param url
|
* @param url
|
||||||
@ -1154,7 +1151,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除URL中的参数
|
* 删除URL中的参数
|
||||||
* @param url
|
* @param url
|
||||||
@ -1168,7 +1165,7 @@ public class Utility implements java.io.Serializable {
|
|||||||
url = url.replaceAll("(\\?" + ParamName +"=[^&]*)", "");
|
url = url.replaceAll("(\\?" + ParamName +"=[^&]*)", "");
|
||||||
url = url.replaceAll("(%3f" + ParamName +"%3d[^&]*)", "");
|
url = url.replaceAll("(%3f" + ParamName +"%3d[^&]*)", "");
|
||||||
url = url.replaceAll("(%3F" + ParamName +"%3D[^&]*)", "");
|
url = url.replaceAll("(%3F" + ParamName +"%3D[^&]*)", "");
|
||||||
|
|
||||||
url = url.replaceAll("(\\&" + ParamName +"=[^&]*)", "");
|
url = url.replaceAll("(\\&" + ParamName +"=[^&]*)", "");
|
||||||
url = url.replaceAll("(%26" + ParamName +"%3d[^&]*)", "");
|
url = url.replaceAll("(%26" + ParamName +"%3d[^&]*)", "");
|
||||||
url = url.replaceAll("(%26" + ParamName +"%3D[^&]*)", "");
|
url = url.replaceAll("(%26" + ParamName +"%3D[^&]*)", "");
|
||||||
@ -1217,6 +1214,25 @@ public class Utility implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
Map<String, Object> map2 = new HashMap<>();
|
||||||
|
map.put("402880817dfaaae1017dfaac17ee0010","主kv");
|
||||||
|
map.put("402880817dfaaae1017dfaac17ee0011","海报");
|
||||||
|
map.put("402880817dfaaae1017dfaac17ee0012","长图");
|
||||||
|
String s2 = "[{\"listValuesId\": 244,\"term\": \"1\"},{\"listValuesId\": 245,\"term\": \"3\"}]";
|
||||||
|
System.out.println(s2);
|
||||||
|
System.out.println(map);
|
||||||
|
String s = JSONObject.toJSONString(map);
|
||||||
|
System.out.println(s);
|
||||||
|
//List<String> list = Arrays.asList(s.split(","));
|
||||||
|
JSONArray jsonArray = JSONObject.parseArray(s2);
|
||||||
|
System.out.println(jsonArray);
|
||||||
|
for (int i = 0; i < jsonArray.size(); i++) {
|
||||||
|
ProjectTaskTerm projectTaskTerm = jsonArray.getObject(i, ProjectTaskTerm.class);
|
||||||
|
projectTaskTerm.setProjectId(UUIDUtil.uuid());
|
||||||
|
projectTaskTerm.setId(UUIDUtil.uuid());
|
||||||
|
System.out.println(projectTaskTerm);
|
||||||
|
}
|
||||||
System.out.println(getDouble2(2.31468d));
|
System.out.println(getDouble2(2.31468d));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,37 +1,17 @@
|
|||||||
spring:
|
spring:
|
||||||
# 数据库配置
|
# 数据库配置
|
||||||
datasource:
|
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
# url: jdbc:mysql://39.108.110.167:13376/xgl_oa?autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=GMT%2B8&characterEncoding=UTF-8
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
# username: root
|
||||||
url: jdbc:mysql://120.25.121.117:3306/xgl_oa?autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=GMT%2B8&characterEncoding=UTF-8
|
# password: 'szxgl@2001B'
|
||||||
username: root
|
#
|
||||||
password: 'szxgl@2001B'
|
# url2: jdbc:mysql://39.108.110.167:13376/xgl_cases?autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=GMT%2B8&characterEncoding=UTF-8
|
||||||
druid:
|
# username2: root
|
||||||
initial-size: 3
|
# password2: 'szxgl@2001B'
|
||||||
min-idle: 1
|
|
||||||
max-active: 500
|
|
||||||
max-wait: 60000 # 获取连接等待超时的时间
|
|
||||||
time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
|
||||||
min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位是毫秒
|
|
||||||
test-while-idle: true # 申请连接的时候检测, 建议配置为true,不影响性能
|
|
||||||
test-on-borrow: false # 申请连接时执行validationQuery检测连接是否有效
|
|
||||||
test-on-return: false # 归还连接时执行validationQuery检测连接是否有效
|
|
||||||
validation-query: SELECT 1
|
|
||||||
log-abandoned: true # 关闭abanded连接时输出错误日志
|
|
||||||
remove-abandoned: false # 是否开启连接泄漏监测,对性能会有一些影响,建议怀疑存在泄漏之后再打开
|
|
||||||
remove-abandoned-timeout: 1800 # 1800秒,也就是30分钟
|
|
||||||
filters: stat, wall
|
|
||||||
web-stat-filter:
|
|
||||||
exclusions: '*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*'
|
|
||||||
stat-view-servlet:
|
|
||||||
enabled: true
|
|
||||||
url-pattern: /druid/*
|
|
||||||
login-username: admin
|
|
||||||
login-password: szxgl.com
|
|
||||||
# Redis配置(springboot2.x版本中默认客户端是用lettuce实现的)
|
# Redis配置(springboot2.x版本中默认客户端是用lettuce实现的)
|
||||||
redis:
|
redis:
|
||||||
database: 0 # Redis数据库索引,默认为0
|
database: 0 # Redis数据库索引,默认为0
|
||||||
host: 120.25.121.117
|
host: 39.108.110.167
|
||||||
port: 8266
|
port: 8266
|
||||||
password: 'Qiween@4531871'
|
password: 'Qiween@4531871'
|
||||||
#timeout: 5000ms # 连接超时时间(毫秒)
|
#timeout: 5000ms # 连接超时时间(毫秒)
|
||||||
@ -44,4 +24,78 @@ spring:
|
|||||||
max-idle: 8 # 连接池中的最大空闲连接
|
max-idle: 8 # 连接池中的最大空闲连接
|
||||||
min-idle: 1 # 连接池中的最小空闲连接
|
min-idle: 1 # 连接池中的最小空闲连接
|
||||||
|
|
||||||
|
data:
|
||||||
|
elasticsearch:
|
||||||
|
repositories:
|
||||||
|
enabled: true # 开启 Elasticsearch仓库(默认值:true)
|
||||||
|
client:
|
||||||
|
reactive:
|
||||||
|
endpoints: 39.108.110.167:9200
|
||||||
|
connection-timeout: 5000
|
||||||
|
socket-timeout: 5000
|
||||||
|
|
||||||
|
datasource:
|
||||||
|
#使用druid连接池
|
||||||
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
|
# 自定义的主数据源配置信息
|
||||||
|
primary:
|
||||||
|
datasource:
|
||||||
|
#druid相关配置
|
||||||
|
druid:
|
||||||
|
#监控统计拦截的filters
|
||||||
|
filters: stat
|
||||||
|
driverClassName: com.mysql.jdbc.Driver
|
||||||
|
#配置基本属性
|
||||||
|
url: jdbc:mysql://39.108.110.167:13376/xgl_oa?autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=GMT%2B8&characterEncoding=UTF-8
|
||||||
|
username: root
|
||||||
|
password: 'szxgl@2001B'
|
||||||
|
#配置初始化大小/最小/最大
|
||||||
|
initialSize: 1
|
||||||
|
minIdle: 1
|
||||||
|
maxActive: 10
|
||||||
|
#获取连接等待超时时间
|
||||||
|
maxWait: 60000
|
||||||
|
#间隔多久进行一次检测,检测需要关闭的空闲连接
|
||||||
|
timeBetweenEvictionRunsMillis: 60000
|
||||||
|
#一个连接在池中最小生存的时间
|
||||||
|
minEvictableIdleTimeMillis: 300000
|
||||||
|
validationQuery: SELECT 'x'
|
||||||
|
testWhileIdle: true
|
||||||
|
testOnBorrow: false
|
||||||
|
testOnReturn: false
|
||||||
|
#打开PSCache,并指定每个连接上PSCache的大小。oracle设为true,mysql设为false。分库分表较多推荐设置为false
|
||||||
|
poolPreparedStatements: false
|
||||||
|
maxPoolPreparedStatementPerConnectionSize: 20
|
||||||
|
# 自定义的从数据源配置信息
|
||||||
|
back:
|
||||||
|
datasource:
|
||||||
|
#druid相关配置
|
||||||
|
druid:
|
||||||
|
#监控统计拦截的filters
|
||||||
|
filters: stat
|
||||||
|
driverClassName: com.mysql.jdbc.Driver
|
||||||
|
#配置基本属性
|
||||||
|
url: jdbc:mysql://39.108.110.167:13376/xgl_cases?autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=GMT%2B8&characterEncoding=UTF-8
|
||||||
|
username: root
|
||||||
|
password: 'szxgl@2001B'
|
||||||
|
#配置初始化大小/最小/最大
|
||||||
|
initialSize: 1
|
||||||
|
minIdle: 1
|
||||||
|
maxActive: 10
|
||||||
|
#获取连接等待超时时间
|
||||||
|
maxWait: 60000
|
||||||
|
#间隔多久进行一次检测,检测需要关闭的空闲连接
|
||||||
|
timeBetweenEvictionRunsMillis: 60000
|
||||||
|
#一个连接在池中最小生存的时间
|
||||||
|
minEvictableIdleTimeMillis: 300000
|
||||||
|
validationQuery: SELECT 'x'
|
||||||
|
testWhileIdle: true
|
||||||
|
testOnBorrow: false
|
||||||
|
testOnReturn: false
|
||||||
|
#打开PSCache,并指定每个连接上PSCache的大小。oracle设为true,mysql设为false。分库分表较多推荐设置为false
|
||||||
|
poolPreparedStatements: false
|
||||||
|
maxPoolPreparedStatementPerConnectionSize: 20
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
# tomcat配置
|
# tomcat配置
|
||||||
server:
|
server:
|
||||||
port: 8080
|
port: 8080
|
||||||
servlet:
|
servlet:
|
||||||
context-path: /worktile
|
context-path: /worktile
|
||||||
jsp:
|
jsp:
|
||||||
init-parameters:
|
init-parameters:
|
||||||
@ -50,7 +50,7 @@ mybatis:
|
|||||||
configuration:
|
configuration:
|
||||||
# 进行自动映射时,数据以下划线命名,如数据库返回的"order_address"命名字段是否映射为class的"orderAddress"字段。默认为false
|
# 进行自动映射时,数据以下划线命名,如数据库返回的"order_address"命名字段是否映射为class的"orderAddress"字段。默认为false
|
||||||
map-underscore-to-camel-case: true
|
map-underscore-to-camel-case: true
|
||||||
|
|
||||||
mapper:
|
mapper:
|
||||||
mappers: com.nbclass.util.MyMapper
|
mappers: com.nbclass.util.MyMapper
|
||||||
not-empty: false
|
not-empty: false
|
||||||
|
|||||||
@ -1,16 +1,21 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.nbclass.szxgl.mapper.ListTypeMapper">
|
<mapper namespace="com.nbclass.szxgl.mapper.ListTypeMapper">
|
||||||
<!--<resultMap id="BaseResultMap" type="com.nbclass.szxgl.model.ListType">-->
|
<resultMap id="BaseResultMap" type="com.nbclass.szxgl.model.ListType">
|
||||||
<!--<id column="id" jdbcType="CHAR" property="id" />-->
|
<id column="id" jdbcType="CHAR" property="id" />
|
||||||
<!--<result column="_list_type" jdbcType="VARCHAR" property="" />-->
|
<result column="list_type" jdbcType="VARCHAR" property="listType" />
|
||||||
<!--<result column="_list_value" jdbcType="VARCHAR" property="list_value" />-->
|
<result column="list_value" jdbcType="VARCHAR" property="listValue" />
|
||||||
<!--</resultMap> -->
|
<collection property="listTypes" ofType="com.nbclass.szxgl.model.ListType" column="id" select="getComboBoxPid">
|
||||||
|
<id column="id" jdbcType="CHAR" property="id" />
|
||||||
|
<result column="list_type" jdbcType="VARCHAR" property="listType" />
|
||||||
|
<result column="list_value" jdbcType="VARCHAR" property="listValue" />
|
||||||
|
</collection>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
<select id="getList" resultType="com.nbclass.szxgl.model.ListType">
|
<select id="getList" resultType="com.nbclass.szxgl.model.ListType">
|
||||||
SELECT * FROM list_values lv WHERE list_type = #{listType}
|
SELECT * FROM list_values lv WHERE list_type = #{listType}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getListValue" resultType="string">
|
<select id="getListValue" resultType="string">
|
||||||
SELECT list_value FROM list_values lv WHERE list_type = #{listType} and id= #{id}
|
SELECT list_value FROM list_values lv WHERE list_type = #{listType} and id= #{id}
|
||||||
</select>
|
</select>
|
||||||
@ -18,4 +23,13 @@
|
|||||||
<select id="getAreaIdByName" resultType="string">
|
<select id="getAreaIdByName" resultType="string">
|
||||||
SELECT id FROM list_values WHERE list_value = #{areaName}
|
SELECT id FROM list_values WHERE list_value = #{areaName}
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
|
||||||
|
<select id="getComboBox" resultMap="BaseResultMap">
|
||||||
|
select * from list_values WHERE parent_id = 0 and parent_id !='' and parent_id is not null
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getComboBoxPid" resultMap="BaseResultMap">
|
||||||
|
select * from list_values WHERE parent_id = #{id} and parent_id !='' and parent_id is not null
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|||||||
22
src/main/resources/mapper/szxgl/ProjectTaskTermMapper.xml
Normal file
22
src/main/resources/mapper/szxgl/ProjectTaskTermMapper.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.nbclass.szxgl.mapper.ProjectTaskTermMapper">
|
||||||
|
|
||||||
|
<insert id="addProjectTaskTerm">
|
||||||
|
insert into project_task_term
|
||||||
|
(
|
||||||
|
id,
|
||||||
|
project_id,
|
||||||
|
list_values_id,
|
||||||
|
term
|
||||||
|
)
|
||||||
|
values
|
||||||
|
(
|
||||||
|
#{id},
|
||||||
|
#{projectId},
|
||||||
|
#{listValuesId},
|
||||||
|
#{term}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
9
src/main/resources/mapper/szxgl/TestMapper.xml
Normal file
9
src/main/resources/mapper/szxgl/TestMapper.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.nbclass.szxgl.mapper2.TestMapper">
|
||||||
|
|
||||||
|
<select id="getContent" resultType="com.nbclass.szxgl.model.Content">
|
||||||
|
select * from content
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
9
src/main/resources/mapper/szxgl/dataDictItemMapper.xml
Normal file
9
src/main/resources/mapper/szxgl/dataDictItemMapper.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.nbclass.szxgl.mapper2.DataDictItemMapper">
|
||||||
|
|
||||||
|
<select id="getTagNames" resultType="java.util.Map">
|
||||||
|
select id,value from data_dict_item where dictid = 25 and value like concat('%',#{tagNames},'%')
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@ -119,4 +119,4 @@
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
0
tmlog0.log
Normal file
0
tmlog0.log
Normal file
Loading…
Reference in New Issue
Block a user