Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6310df17e1 | ||
|
|
344add3121 | ||
|
|
1a48766b99 | ||
|
|
a0e69844fe | ||
|
|
3e08144c3f | ||
|
|
b596159045 | ||
|
|
3ad7f52479 | ||
|
|
1881686bb5 | ||
|
|
9f860d949e | ||
|
|
0af0ca95e1 | ||
|
|
da43d56ecc | ||
|
|
17a9e9f929 | ||
|
|
cbdac61496 | ||
|
|
32c590108d | ||
|
|
32c4b25ff8 | ||
|
|
ba27ad5baf | ||
|
|
929d46a0a7 | ||
|
|
ccdec76633 | ||
|
|
bfb30d33d9 | ||
|
|
c774f40f6f | ||
|
|
c0b58757b1 | ||
|
|
7ed1ce1ca4 | ||
|
|
ff9e29e311 | ||
|
|
ec4c6498e1 | ||
|
|
51fa478fdc | ||
|
|
51f1bd7750 | ||
|
|
88d0c70c94 | ||
|
|
b558bf0fdf | ||
|
|
085c296f81 | ||
|
|
0907e01a13 | ||
|
|
2ddba378d7 | ||
|
|
ec545fb481 | ||
|
|
36b0a6b371 | ||
|
|
2b0d17f4c5 | ||
|
|
76de32261d | ||
|
|
bd3f19162a |
+40
-27
@@ -3,29 +3,12 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>boot-module-demo</artifactId>
|
||||
<artifactId>boot-module-pro</artifactId>
|
||||
<groupId>com.xwbing</groupId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>boot-service</artifactId>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nexus</id>
|
||||
<name>aliyun nexus</name>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>nexus</id>
|
||||
<name>aliyun nexus</name>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
<dependencies>
|
||||
<!-- mail -->
|
||||
<dependency>
|
||||
@@ -33,7 +16,17 @@
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
<!-- 数据库 -->
|
||||
<dependency>
|
||||
<dependency><!-- druid -->
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>${druid-version}</version>
|
||||
</dependency>
|
||||
<dependency> <!-- mysql driver -->
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency> <!-- jpa -->
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
<exclusions>
|
||||
@@ -43,15 +36,20 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency> <!-- druid连接池 -->
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
<version>${druid-version}</version>
|
||||
<dependency> <!-- mybatis -->
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>1.3.1</version>
|
||||
</dependency>
|
||||
<dependency> <!-- mysql driver -->
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<dependency>
|
||||
<groupId>tk.mybatis</groupId>
|
||||
<artifactId>mapper-spring-boot-starter</artifactId>
|
||||
<version>1.2.4</version>
|
||||
</dependency>
|
||||
<dependency> <!-- 分页插件 -->
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.2.3</version>
|
||||
</dependency>
|
||||
<!-- lombok:实体类自动生成getting和setting方法,以及equals,hashCode,toString等 -->
|
||||
<dependency>
|
||||
@@ -129,4 +127,19 @@
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- mybatis generator 自动生成代码插件 -->
|
||||
<plugin>
|
||||
<groupId>org.mybatis.generator</groupId>
|
||||
<artifactId>mybatis-generator-maven-plugin</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<configuration>
|
||||
<configurationFile>${basedir}/src/main/resources/generator/generatorConfig.xml</configurationFile>
|
||||
<overwrite>true</overwrite>
|
||||
<verbose>true</verbose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -2,7 +2,7 @@ package com.xwbing.constant;
|
||||
|
||||
/**
|
||||
* 说明: 公共常量
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 说明: 公共枚举
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建日期: 2016年12月9日 上午9:50:30
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.xwbing.datasource;
|
||||
|
||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
|
||||
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 说明: JpaDataSourceConfig
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/12/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@Configuration
|
||||
@PropertySource("classpath:druid.properties")
|
||||
@EnableJpaRepositories(
|
||||
entityManagerFactoryRef = "jpaEntityManagerFactory",
|
||||
transactionManagerRef = "jpaTransactionManager",
|
||||
basePackages = {"com.xwbing.domain.repository"})
|
||||
public class JpaDataSourceConfig {
|
||||
@Resource
|
||||
private JpaProperties jpaProperties;
|
||||
|
||||
@Bean(name = "jpaDataSource")
|
||||
@ConfigurationProperties("db2")
|
||||
public DataSource dataSource() {
|
||||
return DruidDataSourceBuilder.create().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置entityManagerFactory
|
||||
*
|
||||
* @param builder
|
||||
* @return
|
||||
*/
|
||||
@Bean(name = "jpaEntityManagerFactory")
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder) {
|
||||
return builder
|
||||
.dataSource(dataSource())
|
||||
.properties(getVendorProperties(dataSource()))
|
||||
.packages("com.xwbing.domain.entity")
|
||||
.persistenceUnit("jpaPersistenceUnit")
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置entityManager
|
||||
*
|
||||
* @param builder
|
||||
* @return
|
||||
*/
|
||||
@Bean(name = "japEntityManager")
|
||||
public EntityManager entityManager(EntityManagerFactoryBuilder builder) {
|
||||
return entityManagerFactory(builder).getObject().createEntityManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置事务
|
||||
*
|
||||
* @param builder
|
||||
* @return
|
||||
*/
|
||||
@Bean(name = "jpaTransactionManager")
|
||||
public PlatformTransactionManager dataSourceTransactionManager(EntityManagerFactoryBuilder builder) {
|
||||
return new JpaTransactionManager(entityManagerFactory(builder).getObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取jpa配置信息
|
||||
*
|
||||
* @param dataSource
|
||||
* @return
|
||||
*/
|
||||
private Map<String, String> getVendorProperties(DataSource dataSource) {
|
||||
return jpaProperties.getHibernateProperties(dataSource);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.xwbing.datasource;
|
||||
|
||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
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.context.annotation.PropertySource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* 说明: MybatisDataSourceConfig
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/12/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@Configuration
|
||||
@MapperScan(basePackages = {"com.xwbing.domain.mapper"}, sqlSessionFactoryRef = "mybatisSqlSessionFactory")
|
||||
@PropertySource("classpath:druid.properties")
|
||||
public class MybatisDataSourceConfig {
|
||||
@Primary
|
||||
@ConfigurationProperties("db1")
|
||||
@Bean(name = "mybatisDatasource")
|
||||
public DataSource dataSource() {
|
||||
return DruidDataSourceBuilder.create().build();
|
||||
}
|
||||
|
||||
@Bean(name = "mybatisSqlSessionFactory")
|
||||
public SqlSessionFactory sqlSessionFactory() throws Exception {
|
||||
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
|
||||
sqlSessionFactoryBean.setDataSource(dataSource());
|
||||
sqlSessionFactoryBean.setTypeAliasesPackage("com.xwbing.domain.entity");
|
||||
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:mapper/**/*.xml"));
|
||||
return sqlSessionFactoryBean.getObject();
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean(name = "mybatisTransactionManager")
|
||||
public PlatformTransactionManager dataSourceTransactionManager() {
|
||||
return new DataSourceTransactionManager(dataSource());
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,15 @@
|
||||
package com.xwbing.demo;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.java.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/1/23 14:45
|
||||
* 作者: xiangwb
|
||||
* 说明: 测试用
|
||||
@@ -11,7 +17,9 @@ import lombok.extern.java.Log;
|
||||
@Log
|
||||
public class Ademo {
|
||||
public static void main(String[] args) {
|
||||
|
||||
List<JSONObject> list=new ArrayList<>();
|
||||
Map<String, List<JSONObject>> aa = list.stream().collect(Collectors.groupingBy(obj -> obj.getString("aa")));
|
||||
System.out.println("aa");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,18 +21,18 @@ public class CalendarDemo {
|
||||
*/
|
||||
calendar.set(Calendar.YEAR, 2008);// 年
|
||||
calendar.set(Calendar.MONTH, 7);// 月从0开始,0表示1月
|
||||
/*
|
||||
* 设置日 对应的时间分量常用的: DATE:月中天 DAY_OF-MONTH:月中的天,与DATE一致
|
||||
* DAY_OF_WEEK:周中的天,星期几 DAY_OF_YEAR:年中的天
|
||||
*/
|
||||
/*
|
||||
* 设置日 对应的时间分量常用的: DATE:月中天 DAY_OF-MONTH:月中的天,与DATE一致
|
||||
* DAY_OF_WEEK:周中的天,星期几 DAY_OF_YEAR:年中的天
|
||||
*/
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 8);// 日
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 8);// 时
|
||||
calendar.set(Calendar.MINUTE, 8);// 分
|
||||
calendar.set(Calendar.SECOND, 8);// 秒
|
||||
System.out.println(calendar.getTime());
|
||||
/*
|
||||
* int get(int field) 获取对应的分量的值
|
||||
*/
|
||||
/*
|
||||
* int get(int field) 获取对应的分量的值
|
||||
*/
|
||||
Calendar now = Calendar.getInstance();
|
||||
int year = now.get(Calendar.YEAR);// 获取年
|
||||
int month = now.get(Calendar.MONTH) + 1;// 获取月+1
|
||||
@@ -59,25 +59,25 @@ public class CalendarDemo {
|
||||
now.set(Calendar.MONTH, 1);
|
||||
System.out.println(now.getActualMaximum(Calendar.DAY_OF_MONTH));
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 查看3年2个月零8天以后的日期?
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 查看3年2个月零8天以后的日期?
|
||||
*/
|
||||
Calendar nowTime = Calendar.getInstance();
|
||||
System.out.println(nowTime.getTime());
|
||||
nowTime.add(Calendar.YEAR, 3);
|
||||
nowTime.add(Calendar.MONTH, 2);
|
||||
nowTime.add(Calendar.DAY_OF_YEAR, 8);// 用DAY_OF_YEAR
|
||||
System.out.println(nowTime.getTime());
|
||||
/*
|
||||
* 当遇到类似开发需求: 要求用户输入一个日期,然后对该日期进行一系列的运算 再将计算后的日期显示给用户时。 流程如下:
|
||||
* 1:获取用户输入的日期字符串
|
||||
* 2:使用SimpleDateFormat将其转换为Date
|
||||
* 3:创建一个Calendar。使其表示Date表示的日期
|
||||
* 4:使用Calendar根据需求计算时间
|
||||
* 5:将Calendar转换为一个Date 6:使用SimpleDateFormal将Date转换为字符串后显示给用户
|
||||
*/
|
||||
/*
|
||||
* 当遇到类似开发需求: 要求用户输入一个日期,然后对该日期进行一系列的运算 再将计算后的日期显示给用户时。 流程如下:
|
||||
* 1:获取用户输入的日期字符串
|
||||
* 2:使用SimpleDateFormat将其转换为Date
|
||||
* 3:创建一个Calendar。使其表示Date表示的日期
|
||||
* 4:使用Calendar根据需求计算时间
|
||||
* 5:将Calendar转换为一个Date 6:使用SimpleDateFormal将Date转换为字符串后显示给用户
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
package com.xwbing.demo;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/2/6 10:54
|
||||
* 作者: xiangwb
|
||||
* 说明: apply进行转换,有返回值。accept进行消耗,无返回值
|
||||
@@ -17,8 +15,6 @@ import java.util.concurrent.CompletableFuture;
|
||||
* 参数: Function(函数)有返回值 Consumer(消费者)无返回值
|
||||
*/
|
||||
public class CompletableFutureDemo {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompletableFutureDemo.class);
|
||||
|
||||
/**
|
||||
* 结合两个CompletionStage的结果,进行转化后返回
|
||||
*
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
package com.xwbing.demo;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/7/3 下午8:57
|
||||
* 作者: xiangwb
|
||||
* 说明: 统计分析
|
||||
*/
|
||||
@Slf4j
|
||||
public class CountDemo {
|
||||
public static final String ITEM = "aa,bb";
|
||||
|
||||
/**
|
||||
* 饼图
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static JSONArray pie(List<JSONObject> list) {
|
||||
JSONArray result = new JSONArray();
|
||||
if (list == null) {
|
||||
list = Collections.EMPTY_LIST;
|
||||
}
|
||||
Map<String, List<JSONObject>> collect = list.stream().collect(Collectors.groupingBy(obj -> obj.getString("item")));
|
||||
JSONObject obj;
|
||||
for (String item : ITEM.split(",")) {
|
||||
obj = new JSONObject();
|
||||
obj.put("name", item);
|
||||
List<JSONObject> sample = collect.get(item);
|
||||
if (sample != null) {
|
||||
int sum = sample.stream().mapToInt(value -> value.getInteger("value")).sum();
|
||||
obj.put("value", sum);
|
||||
} else {
|
||||
obj.put("value", 0);
|
||||
}
|
||||
result.add(obj);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* eCharts柱状图/折线图
|
||||
*
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, Object> eChartsBarOrLine(String startDate, String endDate, List<JSONObject> list) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
//统计时间
|
||||
List<String> days = listDate(startDate, endDate);
|
||||
result.put("xAxis", days);
|
||||
if (list == null) {
|
||||
list = Collections.EMPTY_LIST;
|
||||
}
|
||||
Map<String, List<JSONObject>> collect = list.stream().collect(Collectors.groupingBy(obj -> obj.getString("day")));
|
||||
JSONObject obj;
|
||||
JSONArray array;
|
||||
JSONArray series = new JSONArray();
|
||||
//统计数据
|
||||
for (String item : ITEM.split(",")) {
|
||||
obj = new JSONObject();
|
||||
obj.put("name", item);
|
||||
array = new JSONArray();
|
||||
for (String day : days) {
|
||||
List<JSONObject> sample = collect.get(day);
|
||||
if (sample != null) {
|
||||
int sum = sample.stream().filter(it -> item.equals(it.getString("item"))).mapToInt(it -> it.getInteger("value")).sum();
|
||||
array.add(sum);
|
||||
} else {
|
||||
array.add(0);
|
||||
}
|
||||
}
|
||||
obj.put("data", array);
|
||||
series.add(obj);
|
||||
}
|
||||
result.put("series", series);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* g2柱状图
|
||||
*
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, Object> g2Bar(String startDate, String endDate, List<JSONObject> list) {
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
List<String> days = listDate(startDate, endDate);
|
||||
result.put("fields", days);
|
||||
if (list == null) {
|
||||
list = Collections.EMPTY_LIST;
|
||||
}
|
||||
JSONArray array = new JSONArray();
|
||||
Map<String, List<JSONObject>> collect = list.stream().collect(Collectors.groupingBy(obj -> obj.getString("day")));
|
||||
JSONObject obj;
|
||||
for (String item : ITEM.split(",")) {
|
||||
obj = new JSONObject();
|
||||
obj.put("name", item);
|
||||
for (String day : days) {
|
||||
List<JSONObject> sample = collect.get(day);
|
||||
if (sample != null) {
|
||||
int sum = sample.stream().filter(it -> item.equals(it.getString("item"))).mapToInt(it -> it.getInteger("value")).sum();
|
||||
obj.put(day, sum);
|
||||
|
||||
} else {
|
||||
obj.put(day, 0);
|
||||
}
|
||||
}
|
||||
array.add(obj);
|
||||
}
|
||||
result.put("data", array);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* g2折线图
|
||||
*
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public static JSONArray g2Line(String startDate, String endDate, List<JSONObject> list) {
|
||||
JSONArray result = new JSONArray();
|
||||
List<String> days = listDate(startDate, endDate);
|
||||
if (list == null) {
|
||||
list = Collections.EMPTY_LIST;
|
||||
}
|
||||
Map<String, List<JSONObject>> collect = list.stream().collect(Collectors.groupingBy(obj -> obj.getString("day")));
|
||||
JSONObject obj;
|
||||
for (String day : days) {
|
||||
obj = new JSONObject();
|
||||
obj.put("day", day);
|
||||
List<JSONObject> sample = collect.get(day);
|
||||
for (String item : ITEM.split(",")) {
|
||||
if (sample != null) {
|
||||
int sum = sample.stream().filter(it -> item.equals(it.getString("item"))).mapToInt(it -> it.getInteger("value")).sum();
|
||||
obj.put(item, sum);
|
||||
} else {
|
||||
obj.put(item, 0);
|
||||
}
|
||||
}
|
||||
result.add(obj);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟数据列表
|
||||
*
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
private static List<JSONObject> listByDate(String startDate, String endDate) {
|
||||
List<JSONObject> result = new ArrayList<>();
|
||||
List<String> list = listDate(startDate, endDate);
|
||||
JSONObject obj;
|
||||
int i = 0;
|
||||
for (String object : list) {
|
||||
obj = new JSONObject();
|
||||
obj.put("day", object);
|
||||
obj.put("value", ++i);
|
||||
String[] array = ITEM.split(",");
|
||||
obj.put("item", array[new Random().nextInt(array.length)]);
|
||||
result.add(obj);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日期列表
|
||||
*
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
private static List<String> listDate(String startDate, String endDate) {
|
||||
List<String> days = new ArrayList<>();
|
||||
LocalDate start = LocalDate.parse(startDate);
|
||||
LocalDate end = LocalDate.parse(endDate);
|
||||
long len = ChronoUnit.DAYS.between(start, end);
|
||||
for (long i = 0; i <= len; i++) {
|
||||
days.add(start.plusDays(i).toString());
|
||||
}
|
||||
return days;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String startDate = "2018-01-01";
|
||||
String endDate = "2018-01-03";
|
||||
List<JSONObject> list = listByDate(startDate, endDate);
|
||||
// List<JSONObject> list = new ArrayList<>();
|
||||
// List<JSONObject> list = null;
|
||||
log.info("pie:{}", JSON.toJSONString(pie(list), SerializerFeature.PrettyFormat));
|
||||
log.info("eChartsBarOrLine{}", JSON.toJSONString(eChartsBarOrLine(startDate, endDate, list), SerializerFeature.PrettyFormat));
|
||||
log.info("g2Bar{}" + JSON.toJSONString(g2Bar(startDate, endDate, list), SerializerFeature.PrettyFormat));
|
||||
log.info("g2Line{}", JSON.toJSONString(g2Line(startDate, endDate, list), SerializerFeature.PrettyFormat));
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import java.io.InputStream;
|
||||
public class FileDemo {
|
||||
public static void main(String[] args) throws IOException {
|
||||
/*
|
||||
*
|
||||
*
|
||||
* 文件
|
||||
* 尽量使用相对路径
|
||||
* 在eclipse中,"."当前目录,指的是
|
||||
@@ -24,35 +24,35 @@ public class FileDemo {
|
||||
*/
|
||||
//创建文件对象
|
||||
File file = new File("." + File.separator + "demo.txt");//创建文件对象,并不创建文件
|
||||
if(!file.exists()){
|
||||
if (!file.exists()) {
|
||||
file.createNewFile(); //创建文件
|
||||
}
|
||||
if(file.exists()){
|
||||
if (file.exists()) {
|
||||
file.delete();//删除文件
|
||||
}
|
||||
String name = file.getName();//获取文件名
|
||||
long length = file.length();//获取文件大小
|
||||
long time = file.lastModified();//获取文件最后修改时间
|
||||
//查看文件是否具有可运行,可读,可写的权限
|
||||
boolean b=file.canExecute();
|
||||
boolean b1=file.canRead();
|
||||
boolean b2=file.canWrite();
|
||||
boolean b = file.canExecute();
|
||||
boolean b1 = file.canRead();
|
||||
boolean b2 = file.canWrite();
|
||||
boolean isDir = file.isDirectory();//是否为一个目录
|
||||
boolean isFile = file.isFile();//是否为一个文件
|
||||
boolean isHidden=file.isHidden();//是否为一个隐藏文件
|
||||
|
||||
boolean isHidden = file.isHidden();//是否为一个隐藏文件
|
||||
|
||||
/**
|
||||
* 目录
|
||||
*/
|
||||
File dir=new File("demo");
|
||||
File[] subs=dir.listFiles();//获取目录下的所有子项
|
||||
if(!dir.exists()){
|
||||
File dir = new File("demo");
|
||||
File[] subs = dir.listFiles();//获取目录下的所有子项
|
||||
if (!dir.exists()) {
|
||||
dir.mkdir();
|
||||
}else {
|
||||
} else {
|
||||
dir.delete();//空目录才能删除
|
||||
}
|
||||
File dirs =new File("a"+File.separator+"b"+File.separator+"c");
|
||||
if(!dirs.exists()){
|
||||
File dirs = new File("a" + File.separator + "b" + File.separator + "c");
|
||||
if (!dirs.exists()) {
|
||||
/*
|
||||
* 在创建当前目录的同时将不存在的父目录一并创建出来
|
||||
*/
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
public class FileUploadDemo {
|
||||
/**
|
||||
* 获取文件数据
|
||||
*
|
||||
* @param multipartFiles
|
||||
* @return
|
||||
*/
|
||||
@@ -30,11 +31,11 @@ public class FileUploadDemo {
|
||||
JSONObject materialInfo;
|
||||
for (MultipartFile multipartFile : multipartFiles) {
|
||||
if (!multipartFile.isEmpty()) {
|
||||
materialInfo=new JSONObject();
|
||||
materialInfo = new JSONObject();
|
||||
String originName = multipartFile.getOriginalFilename();//原始名字
|
||||
materialInfo.put("name",originName);
|
||||
materialInfo.put("name", originName);
|
||||
String fileType = originName.substring(originName.lastIndexOf(".") + 1);//获取文件后缀名
|
||||
materialInfo.put("type",fileType);
|
||||
materialInfo.put("type", fileType);
|
||||
byte[] data;
|
||||
try {
|
||||
InputStream is = multipartFile.getInputStream();//文件输入流
|
||||
@@ -45,7 +46,7 @@ public class FileUploadDemo {
|
||||
throw new UtilException("读取数据错误");
|
||||
}
|
||||
String base64 = Base64.getEncoder().encodeToString(data);//对数据字节进行base64编码
|
||||
materialInfo.put("data",base64);
|
||||
materialInfo.put("data", base64);
|
||||
list.add(materialInfo);
|
||||
}
|
||||
}
|
||||
@@ -54,30 +55,31 @@ public class FileUploadDemo {
|
||||
|
||||
/**
|
||||
* 采用file.Transto 来保存上传的文件
|
||||
*
|
||||
* @param multipartFile
|
||||
*/
|
||||
public void fileUpload(CommonsMultipartFile multipartFile) {
|
||||
if (!multipartFile.isEmpty()) {
|
||||
String name = multipartFile.getOriginalFilename();//原始名字
|
||||
ClassPathResource file = new ClassPathResource("pic");
|
||||
try {
|
||||
String path = file.getFile().getAbsolutePath();
|
||||
File targetFile = new File(path+ File.separator+name);
|
||||
if (!targetFile.exists()) {
|
||||
targetFile.createNewFile();
|
||||
}
|
||||
multipartFile.transferTo(targetFile);
|
||||
} catch (IOException e) {
|
||||
throw new UtilException("读取数据错误");
|
||||
if (!multipartFile.isEmpty()) {
|
||||
String name = multipartFile.getOriginalFilename();//原始名字
|
||||
ClassPathResource file = new ClassPathResource("pic");
|
||||
try {
|
||||
String path = file.getFile().getAbsolutePath();
|
||||
File targetFile = new File(path + File.separator + name);
|
||||
if (!targetFile.exists()) {
|
||||
targetFile.createNewFile();
|
||||
}
|
||||
multipartFile.transferTo(targetFile);
|
||||
} catch (IOException e) {
|
||||
throw new UtilException("读取数据错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception{
|
||||
public static void main(String[] args) throws Exception {
|
||||
ClassPathResource file = new ClassPathResource("pic");
|
||||
String path = file.getFile().getAbsolutePath();
|
||||
File targetFile = new File(path+ File.separator+"test.txt");
|
||||
if(!targetFile.exists()){
|
||||
File targetFile = new File(path + File.separator + "test.txt");
|
||||
if (!targetFile.exists()) {
|
||||
targetFile.createNewFile(); //创建文件
|
||||
}
|
||||
System.out.println("");
|
||||
|
||||
@@ -35,24 +35,24 @@ public class ForEachMap {
|
||||
};
|
||||
/*
|
||||
* 遍历所有的key
|
||||
* set<k> keySet()
|
||||
* 该方法会将当前map中所有的key存入一个set集合后返回
|
||||
* 那么遍历该集合就等于遍历类所有的key
|
||||
*/
|
||||
* set<k> keySet()
|
||||
* 该方法会将当前map中所有的key存入一个set集合后返回
|
||||
* 那么遍历该集合就等于遍历类所有的key
|
||||
*/
|
||||
Set<String> keySet = map.keySet();
|
||||
for (String key : keySet) {
|
||||
System.out.println(key);
|
||||
}
|
||||
/*
|
||||
* 遍历每一组键值对(推荐)
|
||||
* map中每一组键值对都是由map的内部类:
|
||||
* java.util.map.entry的一个实例类表示的
|
||||
* entry有两个方法:getkey getvalue 可以分别获取这一组键值对中的key和value
|
||||
*
|
||||
* Set<Entry> entrySet
|
||||
* 该方法会将map中的每一组键对(entry实例)
|
||||
* 存入一个set集合后返回
|
||||
*/
|
||||
* map中每一组键值对都是由map的内部类:
|
||||
* java.util.map.entry的一个实例类表示的
|
||||
* entry有两个方法:getkey getvalue 可以分别获取这一组键值对中的key和value
|
||||
*
|
||||
* Set<Entry> entrySet
|
||||
* 该方法会将map中的每一组键对(entry实例)
|
||||
* 存入一个set集合后返回
|
||||
*/
|
||||
Set<Entry<String, Integer>> entrySet = map.entrySet();
|
||||
for (Entry<String, Integer> e : entrySet) {
|
||||
String key = e.getKey();
|
||||
@@ -61,9 +61,9 @@ public class ForEachMap {
|
||||
}
|
||||
/*
|
||||
* 遍历所有的value
|
||||
* Collection values()
|
||||
* 该方法会将当前map中所有的value存入一个集合后返回
|
||||
*/
|
||||
* Collection values()
|
||||
* 该方法会将当前map中所有的value存入一个集合后返回
|
||||
*/
|
||||
Collection<Integer> values = map.values();
|
||||
for (Integer value : values) {
|
||||
System.out.println(value);
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.xwbing.demo;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/4/16 14:10
|
||||
* 作者: xiangwb
|
||||
* 说明: 猜字谜游戏
|
||||
|
||||
@@ -16,17 +16,15 @@ public class IODemo {
|
||||
*/
|
||||
|
||||
/**
|
||||
* 写
|
||||
* 字节流
|
||||
*/
|
||||
FileOutputStream fos = new FileOutputStream("fos.txt", true);//追加写模式
|
||||
fos.write("你好".getBytes("utf-8"));
|
||||
/* 写 */
|
||||
FileOutputStream fos = new FileOutputStream("io.txt", true);//追加写模式
|
||||
fos.write("字节流".getBytes("utf-8"));
|
||||
System.out.println("写出完毕");
|
||||
fos.close();//关闭流
|
||||
|
||||
/**
|
||||
* 读
|
||||
*/
|
||||
FileInputStream fis = new FileInputStream("fos.txt");
|
||||
/* 读 */
|
||||
FileInputStream fis = new FileInputStream("io.txt");
|
||||
byte[] data = new byte[fis.available()];
|
||||
int len = fis.read(data);//数据读入data里
|
||||
String str = new String(data, 0, len, "utf-8");
|
||||
@@ -36,38 +34,37 @@ public class IODemo {
|
||||
byte[] da = new byte[is.available()];
|
||||
is.read(da);
|
||||
is.close();
|
||||
/**
|
||||
* 缓冲流
|
||||
*
|
||||
*/
|
||||
BufferedOutputStream bos = new BufferedOutputStream(fos);
|
||||
bos.write("你好".getBytes());
|
||||
bos.close();//close前会自动flush,关流只需管最外层高级流
|
||||
|
||||
|
||||
/**
|
||||
* 使用缓冲流的形式复制文件
|
||||
* 缓冲流
|
||||
*/
|
||||
BufferedInputStream bis1 = new BufferedInputStream(fis);
|
||||
BufferedOutputStream bos1 = new BufferedOutputStream(fos);
|
||||
/* 写 */
|
||||
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("io.txt", true));
|
||||
bos.write("缓冲流".getBytes());
|
||||
bos.close();//close前会自动flush,关流只需管最外层高级流
|
||||
/* 使用缓冲流的形式复制文件 */
|
||||
BufferedInputStream bis1 = new BufferedInputStream(new FileInputStream("io.txt"));
|
||||
BufferedOutputStream bos1 = new BufferedOutputStream(new FileOutputStream("io.txt", true));
|
||||
int d;
|
||||
while ((d = bis1.read()) != -1) {
|
||||
bos1.write(d);
|
||||
}
|
||||
bis1.close();
|
||||
bos1.close();
|
||||
|
||||
/*
|
||||
|
||||
/**
|
||||
* 字符流
|
||||
* 读写单位是字符
|
||||
* 可以按照指定的字符集,将写出的字符转换为对应的字节
|
||||
* 字符流只适合读写文本数据
|
||||
* 转码:uft-8转gbk
|
||||
*/
|
||||
InputStreamReader isr = new InputStreamReader(fis, "utf-8");
|
||||
OutputStreamWriter osw = new OutputStreamWriter(fos, "gbk");
|
||||
int leng;
|
||||
while ((leng = isr.read()) != -1) {
|
||||
osw.write(leng);
|
||||
InputStreamReader isr = new InputStreamReader(new FileInputStream("io.txt"), "utf-8");
|
||||
OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("io.tex"), "gbk");
|
||||
int length;
|
||||
while ((length = isr.read()) != -1) {
|
||||
osw.write(length);
|
||||
}
|
||||
osw.close();
|
||||
isr.close();
|
||||
@@ -75,7 +72,7 @@ public class IODemo {
|
||||
/**
|
||||
* 缓冲字符输入流,特点:读取速度快,并且可以按行读取字符串
|
||||
*/
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("fis.txt")));
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("io.txt")));
|
||||
String line = null;
|
||||
//readerLIne():连续读取若干字符,知道遇到换行符为止,该字符串中不包含换行符
|
||||
while ((line = br.readLine()) != null) {
|
||||
@@ -86,11 +83,10 @@ public class IODemo {
|
||||
/**
|
||||
* 缓冲字符输出流
|
||||
*/
|
||||
PrintWriter pw = new PrintWriter("e.txt", "utf-8");//PrintWriter可以直接创建基于文件进行写操作
|
||||
PrintWriter pw = new PrintWriter("io.txt", "utf-8");//PrintWriter可以直接创建基于文件进行写操作
|
||||
pw.close();
|
||||
|
||||
FileOutputStream fos1 = new FileOutputStream("pw1.txt");
|
||||
OutputStreamWriter osw1 = new OutputStreamWriter(fos, "utf-8");//可以指定字符
|
||||
PrintWriter pw1 = new PrintWriter(osw, true);//当第一个参数为流,可以使用第二个参数来指定是否自动flush
|
||||
PrintWriter pw1 = new PrintWriter(new OutputStreamWriter(new FileOutputStream("io.txt"),"utf-8"), true);//当第一个参数为流,可以使用第二个参数来指定是否自动flush
|
||||
pw1.println("......");
|
||||
pw1.close();
|
||||
}
|
||||
|
||||
@@ -52,15 +52,15 @@ public class Java8DateDemo {
|
||||
LocalTime specificSecondTime = LocalTime.ofSecondOfDay(1);// 00:00:01
|
||||
|
||||
LocalDateTime dateTime = date.atTime(time);// Create LocalDateTime from
|
||||
// LocalDate
|
||||
// LocalDate
|
||||
LocalDateTime today = LocalDateTime.now();// Current Date
|
||||
today = LocalDateTime.of(LocalDate.now(), LocalTime.now());
|
||||
LocalDateTime specificDate = LocalDateTime.of(2014, Month.JANUARY, 1,
|
||||
10, 10, 30);// 2014-01-01T10:10:30
|
||||
LocalDateTime todayKolkata1 = LocalDateTime.now(ZoneId
|
||||
.of("Asia/Kolkata"));
|
||||
int second=today.getSecond();//获取时间中的秒
|
||||
int week=today.getDayOfWeek().getValue();//获取周几
|
||||
int second = today.getSecond();//获取时间中的秒
|
||||
int week = today.getDayOfWeek().getValue();//获取周几
|
||||
|
||||
/*
|
||||
* 时钟
|
||||
@@ -73,8 +73,8 @@ public class Java8DateDemo {
|
||||
/*
|
||||
*新旧日期转换
|
||||
*/
|
||||
Instant instant = new Date().toInstant();
|
||||
Date dateee = Date.from(instant);
|
||||
Instant instant = new Date().toInstant();
|
||||
Date dateee = Date.from(instant);
|
||||
|
||||
/*
|
||||
* 时间相差
|
||||
|
||||
@@ -107,7 +107,7 @@ public class LambdaDemo {
|
||||
// try {
|
||||
// completableFuture.get();
|
||||
// } catch (InterruptedException | ExecutionException e) {
|
||||
// logger.error(e.getMessage());
|
||||
// log.error(e.getMessage());
|
||||
// throw new BusinessException("获取数据出错");
|
||||
// }
|
||||
return finalList;
|
||||
|
||||
@@ -4,26 +4,26 @@ import java.io.File;
|
||||
|
||||
/**
|
||||
* 删除一个含有子项的目录
|
||||
*
|
||||
* @author xiangwb
|
||||
*
|
||||
* @author xiangwb
|
||||
*/
|
||||
public class RecursiveFIle {
|
||||
public static void main(String[] args) {
|
||||
File dir = new File("C:\\Users\\admin\\Desktop\\123");
|
||||
deleteFile(dir);
|
||||
}
|
||||
/*
|
||||
* 将给定的file表示的文件或目录删除
|
||||
*/
|
||||
public static void deleteFile(File f) {
|
||||
if(f.isDirectory()){
|
||||
//将该目录下的所有子项删除
|
||||
File[] subs=f.listFiles();
|
||||
for(File sub:subs){
|
||||
deleteFile(sub);
|
||||
}
|
||||
}
|
||||
f.delete();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
File dir = new File("C:\\Users\\admin\\Desktop\\123");
|
||||
deleteFile(dir);
|
||||
}
|
||||
|
||||
/*
|
||||
* 将给定的file表示的文件或目录删除
|
||||
*/
|
||||
public static void deleteFile(File f) {
|
||||
if (f.isDirectory()) {
|
||||
//将该目录下的所有子项删除
|
||||
File[] subs = f.listFiles();
|
||||
for (File sub : subs) {
|
||||
deleteFile(sub);
|
||||
}
|
||||
}
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/2/27 17:32
|
||||
* 作者: xiangwb
|
||||
* ---------------------------------------------------
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/5/27 20:37
|
||||
* 作者: xiangwb
|
||||
* 说明: Java反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法;
|
||||
|
||||
@@ -29,8 +29,8 @@ public class ThreadSyncDemo {
|
||||
Thread t2 = new Thread(s::buy);
|
||||
t1.start();
|
||||
t2.start();
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 静态方法锁
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ public class ThreadSyncDemo {
|
||||
Thread tt2 = new Thread(ThreadSyncDemo::doSome);
|
||||
tt1.start();
|
||||
tt2.start();
|
||||
|
||||
|
||||
/*
|
||||
* 互斥
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.xwbing.demo;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.List;
|
||||
|
||||
import org.dom4j.Attribute;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentHelper;
|
||||
@@ -18,80 +19,78 @@ import org.dom4j.io.XMLWriter;
|
||||
|
||||
public class XmlDemo {
|
||||
|
||||
/**
|
||||
*
|
||||
* 功能描述:将doc对象(xml)写到文件中
|
||||
* 作 者:xwb
|
||||
* 创建时间:2017年2月16日 下午2:59:26
|
||||
*
|
||||
* @param doc
|
||||
* @param xml
|
||||
* @throws Exception
|
||||
*/
|
||||
private static void write2xml(Document doc, String fos) throws Exception {
|
||||
FileOutputStream out = new FileOutputStream(fos);
|
||||
// dom4j 提供类格式工具,可以输出时候对doc进行化妆,搞漂亮一些
|
||||
OutputFormat fmt = OutputFormat.createPrettyPrint();
|
||||
XMLWriter writer = new XMLWriter(out, fmt);// 格式
|
||||
writer.write(doc);
|
||||
writer.close();
|
||||
}
|
||||
/**
|
||||
* 功能描述:将doc对象(xml)写到文件中
|
||||
* 作 者:xwb
|
||||
* 创建时间:2017年2月16日 下午2:59:26
|
||||
*
|
||||
* @param doc
|
||||
* @param xml
|
||||
* @throws Exception
|
||||
*/
|
||||
private static void write2xml(Document doc, String fos) throws Exception {
|
||||
FileOutputStream out = new FileOutputStream(fos);
|
||||
// dom4j 提供类格式工具,可以输出时候对doc进行化妆,搞漂亮一些
|
||||
OutputFormat fmt = OutputFormat.createPrettyPrint();
|
||||
XMLWriter writer = new XMLWriter(out, fmt);// 格式
|
||||
writer.write(doc);
|
||||
writer.close();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 功能描述: 读取XML文件到doc对象
|
||||
* 作 者:xwb
|
||||
* 创建时间:2017年2月16日 下午3:01:33
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private static Document readXml(String fis) throws Exception {
|
||||
SAXReader reader = new SAXReader();
|
||||
FileInputStream in = new FileInputStream(fis);
|
||||
Document doc = reader.read(in);
|
||||
return doc;
|
||||
}
|
||||
/**
|
||||
* 功能描述: 读取XML文件到doc对象
|
||||
* 作 者:xwb
|
||||
* 创建时间:2017年2月16日 下午3:01:33
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private static Document readXml(String fis) throws Exception {
|
||||
SAXReader reader = new SAXReader();
|
||||
FileInputStream in = new FileInputStream(fis);
|
||||
Document doc = reader.read(in);
|
||||
return doc;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Document doc = readXml("xmlDemo.xml");
|
||||
System.out.println(doc.asXML() + "...............");
|
||||
public static void main(String[] args) throws Exception {
|
||||
Document doc = readXml("xmlDemo.xml");
|
||||
System.out.println(doc.asXML() + "...............");
|
||||
|
||||
// doc 是全部的XML文件的内容
|
||||
// doc 引用的是内存中的对象。
|
||||
Element root = doc.getRootElement();// 获取xml的根元素,访问xml中数据的唯一入口
|
||||
// 获取根元素下所有子元素,并遍历
|
||||
List<Element> list = root.elements();
|
||||
for (Element e2 : list) {
|
||||
System.out.println(e2.getName());// 获取元素名字
|
||||
System.out.println(e2.getText());// 获取元素内文本内容
|
||||
}
|
||||
// doc 是全部的XML文件的内容
|
||||
// doc 引用的是内存中的对象。
|
||||
Element root = doc.getRootElement();// 获取xml的根元素,访问xml中数据的唯一入口
|
||||
// 获取根元素下所有子元素,并遍历
|
||||
List<Element> list = root.elements();
|
||||
for (Element e2 : list) {
|
||||
System.out.println(e2.getName());// 获取元素名字
|
||||
System.out.println(e2.getText());// 获取元素内文本内容
|
||||
}
|
||||
|
||||
Element book = root.element("book");// 获取满足第一个条件的子元素
|
||||
Element name = book.element("name");
|
||||
name.setText("轶名名");// 修改元素内容
|
||||
Attribute id = book.attribute("id");// 获取属性
|
||||
System.out.println(id.getValue());
|
||||
id.setValue("b3");// 修改属性
|
||||
Element book = root.element("book");// 获取满足第一个条件的子元素
|
||||
Element name = book.element("name");
|
||||
name.setText("轶名名");// 修改元素内容
|
||||
Attribute id = book.attribute("id");// 获取属性
|
||||
System.out.println(id.getValue());
|
||||
id.setValue("b3");// 修改属性
|
||||
|
||||
// 如果修改了doc 就能实现修改xml并写文件
|
||||
// 为根元素添加子元素
|
||||
Element newOne = root.addElement("book8");
|
||||
newOne.addElement("name").setText("18岁给我一姑娘");
|
||||
newOne.addAttribute("id", "b5");
|
||||
newOne.addAttribute("lang", "中文");
|
||||
// 如果修改了doc 就能实现修改xml并写文件
|
||||
// 为根元素添加子元素
|
||||
Element newOne = root.addElement("book8");
|
||||
newOne.addElement("name").setText("18岁给我一姑娘");
|
||||
newOne.addAttribute("id", "b5");
|
||||
newOne.addAttribute("lang", "中文");
|
||||
|
||||
// 找到元素并且删除这个子元素
|
||||
Element book1 = root.element("book8");
|
||||
root.remove(book1);
|
||||
write2xml(doc, "demo.xml");
|
||||
// 找到元素并且删除这个子元素
|
||||
Element book1 = root.element("book8");
|
||||
root.remove(book1);
|
||||
write2xml(doc, "demo.xml");
|
||||
|
||||
// 创建新的xml document对象
|
||||
Document newDoc = DocumentHelper.createDocument();
|
||||
// 为doc添加根元素
|
||||
Element newRoot = newDoc.addElement("students");
|
||||
newRoot.addElement("stu1");
|
||||
newRoot.addElement("stu2");
|
||||
write2xml(newDoc, "xmlDemoStu.xml");
|
||||
}
|
||||
// 创建新的xml document对象
|
||||
Document newDoc = DocumentHelper.createDocument();
|
||||
// 为doc添加根元素
|
||||
Element newRoot = newDoc.addElement("students");
|
||||
newRoot.addElement("stu1");
|
||||
newRoot.addElement("stu2");
|
||||
write2xml(newDoc, "xmlDemoStu.xml");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,10 +27,10 @@ public class Client {
|
||||
try {
|
||||
/*
|
||||
* 初始化socket需要传入两个参数: 1:远程计算机的ip地址 2:服务端应用程序在服务器上申请的端口
|
||||
* 我们是通过ip地址找到服务器的计算机,在通过端口找到该机器上的服务端应用 程序,这个端口不是客户端决定的,而是服务端决定的
|
||||
*
|
||||
* 实例化socket的过程就是连接的过程 若服务端没有响应,这里会抛出异常
|
||||
*/
|
||||
* 我们是通过ip地址找到服务器的计算机,在通过端口找到该机器上的服务端应用 程序,这个端口不是客户端决定的,而是服务端决定的
|
||||
*
|
||||
* 实例化socket的过程就是连接的过程 若服务端没有响应,这里会抛出异常
|
||||
*/
|
||||
socket = new Socket("localhost", 7851);
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
@@ -44,8 +44,8 @@ public class Client {
|
||||
Thread t = new Thread(handler);
|
||||
t.start();
|
||||
/*
|
||||
* outputstream getoutputstream() 通过socket获取输出流,用来将数据发送至服务端
|
||||
*/
|
||||
* outputstream getoutputstream() 通过socket获取输出流,用来将数据发送至服务端
|
||||
*/
|
||||
Scanner sc = new Scanner(System.in);
|
||||
OutputStream out = socket.getOutputStream();
|
||||
OutputStreamWriter osw = new OutputStreamWriter(out, "utf-8");
|
||||
|
||||
@@ -35,9 +35,9 @@ public class Server {
|
||||
public Server() throws Exception {
|
||||
try {
|
||||
/*
|
||||
* 初始化serversocket并指定服务端口
|
||||
* 该端口不能与其他应用程序冲突,否则会抛出异常
|
||||
*/
|
||||
* 初始化serversocket并指定服务端口
|
||||
* 该端口不能与其他应用程序冲突,否则会抛出异常
|
||||
*/
|
||||
server = new ServerSocket(7851);
|
||||
allOut = new ArrayList<>();
|
||||
} catch (Exception e) {
|
||||
@@ -79,12 +79,12 @@ public class Server {
|
||||
*/
|
||||
public void start() {
|
||||
try {
|
||||
/*
|
||||
* scoket accept()
|
||||
* serversocket提供了accept方法,该方法用于监听申请的服务端口,直到一个客户端连接
|
||||
* 然后返回一个socket实例用于与该客户端通讯
|
||||
* 这个方法是一个阻塞方法,直到客户端连接返回继续向下执行
|
||||
*/
|
||||
/*
|
||||
* scoket accept()
|
||||
* serversocket提供了accept方法,该方法用于监听申请的服务端口,直到一个客户端连接
|
||||
* 然后返回一个socket实例用于与该客户端通讯
|
||||
* 这个方法是一个阻塞方法,直到客户端连接返回继续向下执行
|
||||
*/
|
||||
while (true) {
|
||||
System.out.println("等待客户端连接");
|
||||
Socket socket = server.accept();
|
||||
@@ -122,10 +122,10 @@ public class Server {
|
||||
|
||||
ClientHandler(Socket socket) {
|
||||
this.socket = socket;
|
||||
/*
|
||||
* 通过socket可以获取远程计算机地址信息
|
||||
* 对于服务端这边而言,远程计算机即客户端
|
||||
*/
|
||||
/*
|
||||
* 通过socket可以获取远程计算机地址信息
|
||||
* 对于服务端这边而言,远程计算机即客户端
|
||||
*/
|
||||
InetAddress address = socket.getInetAddress();
|
||||
// 获取ip地址的字符串形式
|
||||
host = address.getHostAddress();
|
||||
@@ -137,31 +137,31 @@ public class Server {
|
||||
try {
|
||||
//通知所有客户该客户端上线了
|
||||
sendMessage("[" + host + "]" + "上线了!");
|
||||
/*
|
||||
* 通过Socket获取输出流,用于将消息发送
|
||||
* 给客户端
|
||||
*/
|
||||
/*
|
||||
* 通过Socket获取输出流,用于将消息发送
|
||||
* 给客户端
|
||||
*/
|
||||
OutputStream out = socket.getOutputStream();
|
||||
OutputStreamWriter osw = new OutputStreamWriter(out, "utf-8");
|
||||
pw = new PrintWriter(osw, true);
|
||||
//将该客户端的输出流存入共享集合
|
||||
addOut(pw);
|
||||
/*
|
||||
* inputstream getinputstream()
|
||||
* socket提供的该方法用来获取一个输入流
|
||||
* 通过该输入流可以读取远端计算机发送过来的数据
|
||||
*/
|
||||
/*
|
||||
* inputstream getinputstream()
|
||||
* socket提供的该方法用来获取一个输入流
|
||||
* 通过该输入流可以读取远端计算机发送过来的数据
|
||||
*/
|
||||
InputStream in = socket.getInputStream();
|
||||
InputStreamReader isr = new InputStreamReader(in, "utf-8");
|
||||
BufferedReader br = new BufferedReader(isr);
|
||||
//读取客户端发送过来的消息
|
||||
String message;
|
||||
/*
|
||||
* 服务端接受客户端发送过来的消息时,由于客户端操作系统不同,
|
||||
* 那么当客户端断开连接时的效果也不相同,
|
||||
* 当windows的客户端断开连接后,br.readline方法会抛出异常
|
||||
* 当linux的客户端断开连接后,br.readline会返回null
|
||||
*/
|
||||
/*
|
||||
* 服务端接受客户端发送过来的消息时,由于客户端操作系统不同,
|
||||
* 那么当客户端断开连接时的效果也不相同,
|
||||
* 当windows的客户端断开连接后,br.readline方法会抛出异常
|
||||
* 当linux的客户端断开连接后,br.readline会返回null
|
||||
*/
|
||||
while ((message = br.readLine()) != null) {
|
||||
// System.out.println(host+"说:"+message);
|
||||
// pw.println(host+"说:"+message);
|
||||
@@ -169,17 +169,17 @@ public class Server {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} finally {
|
||||
/*
|
||||
* 客户端与服务端断开后
|
||||
*/
|
||||
/*
|
||||
* 客户端与服务端断开后
|
||||
*/
|
||||
try {
|
||||
//将该客户端的输出流从共享集合中删除
|
||||
removeOut(pw);
|
||||
//下线
|
||||
sendMessage("[" + host + "]" + "下线了!");
|
||||
/*
|
||||
* 通讯完毕后,应当socekt关闭,以释放底层资源
|
||||
*/
|
||||
/*
|
||||
* 通讯完毕后,应当socekt关闭,以释放底层资源
|
||||
*/
|
||||
socket.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
CREATE TABLE employee_xwbin(
|
||||
id NUMBER(4) DEFAULT 1 ,
|
||||
name VARCHAR2(20),
|
||||
gender CHAR(1) DEFAULT 'M',
|
||||
biith DATE,
|
||||
salary NUMBER(6,2),
|
||||
job VARCHAR2(30),
|
||||
deptno NUMBER(2)
|
||||
);
|
||||
DROP TABLE name4;
|
||||
NOT NULL 约束可以确保指定的字段不允许为null
|
||||
CREATE TABLE employ_xwbing(
|
||||
DDL
|
||||
CREATE TABLE xwbing(
|
||||
id NUMBER(4) DEFAULT 1,
|
||||
name VARCHAR2(20) NOT NULL,
|
||||
gender CHAR(1) DEFAULT 'M',
|
||||
@@ -19,120 +9,41 @@ CREATE TABLE employ_xwbing(
|
||||
deptno NUMBER(2) DEFAULT 1
|
||||
)
|
||||
DESC xwbing;
|
||||
DROP TABLE xwbing;
|
||||
RENAME employ_xwbing TO xwbing;
|
||||
DESC xwbing;
|
||||
修改表的
|
||||
向表中添加新的字段,只能在当前表的末尾追加,可以同时追加多个列,只需要使用逗号隔开即可,与创建声明列的时候语法一样
|
||||
ALTER TABLE XWBING ADD(
|
||||
HIREDATE DATE DEFAULT SYSDATE
|
||||
)
|
||||
删除表中现有字段
|
||||
|
||||
|
||||
DML
|
||||
用于修改表中数据,分为:增 删 改
|
||||
插入数据
|
||||
INSERT INTO XWBING (id,name,job,salary)
|
||||
VALUES(1,'JACK','CLERK',5000)
|
||||
COMMIT
|
||||
INSERT INTO XWBING (id,name,job,salary) VALUES(1,'JACK','CLERK',5000)
|
||||
插入日期类型,建议使用TO-DATE函数
|
||||
可以使用字符串 但是格式必须是'DD-MON-RR'
|
||||
由于有语言差异,不推荐
|
||||
INSERT INTO XWBING(id,name,job,birth)
|
||||
VALUES(2,'ROSE','CLERK',TO_DATE('1992-08-02','YYYY-MM-DD'))
|
||||
SELECT *FROM XWBING;
|
||||
|
||||
ALTER TABLE XWBING DROP(HIREDATE)
|
||||
|
||||
INSERT INTO XWBING(id,name,job,birth) VALUES(2,'ROSE','CLERK',TO_DATE('1992-08-02','YYYY-MM-DD'))
|
||||
修改表中现有字段
|
||||
可以修改字段的类型,长度,默认值,非空
|
||||
ALTER TABLE XWBING MODIFY(
|
||||
job VARCHAR2(40) DEFAULT 'CLERK'
|
||||
)
|
||||
|
||||
修改表中现有数据
|
||||
将rose的工资改为5500
|
||||
UPDATE XWBING SET SALARY=50000 WHERE name='ROSE' 字符串里区分大小写,用''
|
||||
|
||||
修改表中的数据的时候,通常要使用WHERE下限定条件,这样只会将满足条件的记录进行修改,
|
||||
若不在指定WHERE则是全表所有的数据都修改
|
||||
|
||||
删除表中数据
|
||||
将rose删除
|
||||
DELETE FROM EMP_XWBING WHERE name='ROSE'
|
||||
DELETE FROM EMP_XWBING
|
||||
删除表中数据同样要用WHERE添加过滤条件 否则就是清空表操作
|
||||
|
||||
CREATE TABLE emp_xwbing(
|
||||
empno NUMBER(4,0),
|
||||
ename VARCHAR2(10),
|
||||
job VARCHAR2(9),
|
||||
mgr NUMBER(4,0),
|
||||
hiredate DATE,
|
||||
sal NUMBER(7,2),
|
||||
comm NUMBER(7,2),
|
||||
deptno NUMBER(2,0)
|
||||
)
|
||||
SELECT *FROM EMP_XWBING;
|
||||
DESC emp_xwbing;
|
||||
CREATE TABLE dept_xwbing(
|
||||
deptno NUMBER(2,0),
|
||||
dname VARCHAR2(14 BYTE),
|
||||
loc VARCHAR2(13 BYTE)
|
||||
)
|
||||
|
||||
INSERT INTO emp_xwbing(empno, ename,job,mgr,hiredate,sal,deptno)
|
||||
VALUES(7369,'SMITH','CLERK',7902,TO_DATE('1980/12/17','YYYY-MM-DD'),800.00,20);
|
||||
INSERT INTO emp_xwbing(empno, ename,job,mgr,hiredate,sal,comm,deptno)
|
||||
VALUES(7499,'ALLEN','SALESMAN',7698,TO_DATE('1981/02/20','YYYY-MM-DD'),1600.00,300.00,30);
|
||||
INSERT INTO emp_xwbing(empno, ename,job,mgr,hiredate,sal,comm,deptno)
|
||||
VALUES(7521,'WARD','SALESMAN',7698,TO_DATE('1981/02/22','YYYY-MM-DD'),1250.00,500.00,30);
|
||||
INSERT INTO emp_xwbing(empno, ename,job,mgr,hiredate,sal,deptno)
|
||||
VALUES(7566,'JONES','MANAGER',7839,TO_DATE('1980/4/2','YYYY-MM-DD'),2975.00,20);
|
||||
INSERT INTO emp_xwbing(empno, ename,job,mgr,hiredate,sal,comm,deptno)
|
||||
VALUES(7654,'MARTIN','SALESMAN',7698,TO_DATE('1981/9/28','YYYY-MM-DD'),1250.00,1400.00,30);
|
||||
INSERT INTO emp_xwbing(empno, ename,job,mgr,hiredate,sal,deptno)
|
||||
VALUES(7698,'BLACK','MANAGER',7839,TO_DATE('1980/5/1','YYYY-MM-DD'),2850.00,30);
|
||||
INSERT INTO emp_xwbing(empno, ename,job,mgr,hiredate,sal,deptno)
|
||||
VALUES(7782,'CLARK','MANAGER',7839,TO_DATE('1980/6/9','YYYY-MM-DD'),2450.00,10);
|
||||
INSERT INTO emp_xwbing(empno, ename,job,mgr,hiredate,sal,deptno)
|
||||
VALUES(7788,'SCOTT','ANALYST',7566,TO_DATE('1987/4/19','YYYY-MM-DD'),3000.00,20);
|
||||
INSERT INTO emp_xwbing(empno, ename,job,hiredate,sal,deptno)
|
||||
VALUES(7839,'KING','PRESIDENT',TO_DATE('1981/11/17','YYYY-MM-DD'),5000.00,10);
|
||||
INSERT INTO emp_xwbing(empno, ename,job,mgr,hiredate,sal,comm,deptno)
|
||||
VALUES(7844,'TURNER','SALESMAN',7698,TO_DATE('1981/9/8','YYYY-MM-DD'),1500.00,0.00,30);
|
||||
INSERT INTO emp_xwbing(empno, ename,job,mgr,hiredate,sal,deptno)
|
||||
VALUES(7876,'ADAMS','CLERK',7788,TO_DATE('1987/5/23','YYYY-MM-DD'),1100.00,20);
|
||||
INSERT INTO emp_xwbing(empno, ename,job,mgr,hiredate,sal,deptno)
|
||||
VALUES(7900,'JAMES','CLERK',7698,TO_DATE('1981/12/3','YYYY-MM-DD'),9500.00,30);
|
||||
INSERT INTO emp_xwbing(empno, ename,job,mgr,hiredate,sal,deptno)
|
||||
VALUES(7902,'FORD','ANALYST',7566,TO_DATE('1981/12/3','YYYY-MM-DD'),3000.00,20);
|
||||
INSERT INTO emp_xwbing(empno, ename,job,mgr,hiredate,sal,deptno)
|
||||
VALUES(7934,'MILLER','CLERK',7782,TO_DATE('1982/1/23','YYYY-MM-DD'),1300.00,10);
|
||||
|
||||
INSERT INTO dept_xwbing(deptno,dname,loc)
|
||||
VALUES(10,'ACCOUNTING','NEW YORK');
|
||||
INSERT INTO dept_xwbing(deptno,dname,loc)
|
||||
VALUES(20,'RESEARCH','DALLAS');
|
||||
INSERT INTO dept_xwbing(deptno,dname,loc)
|
||||
VALUES(30,'SALES','CHICAGO');
|
||||
INSERT INTO dept_xwbing(deptno,dname,loc)
|
||||
VALUES(40,'OPERATIONS','BOSTON');
|
||||
select *from dept_xwbing;
|
||||
|
||||
|
||||
create table name2 (
|
||||
deptno NUMBER(2,0),
|
||||
dname VARCHAR2(14 BYTE),
|
||||
loc VARCHAR2(13 BYTE)
|
||||
);
|
||||
INSERT INTO name2(deptno,dname,loc)
|
||||
VALUES(10,'ACCOUNTING','NEW YORK');
|
||||
INSERT INTO name2(deptno,dname,loc)
|
||||
VALUES(20,'RESEARCH','DALLAS');
|
||||
INSERT INTO name2(deptno,dname,loc)
|
||||
VALUES(30,'SALES','CHICAGO');
|
||||
DQL
|
||||
SELECT语句
|
||||
SELECT是用来查询数据的语句DQL
|
||||
查询某张表中的所有字段的记录:
|
||||
SELECT * FROM EMP_XWBING;
|
||||
查看指定字段的值:
|
||||
SELECT ename,sal,job FROM EMP_XWBING;
|
||||
|
||||
SELECT *FROM name4;
|
||||
alter table name2 modify(deptno NUMBER(4,0),
|
||||
dname VARCHAR2(14 BYTE))
|
||||
DQL必须包含的部分是SELECT子句与FROM子句
|
||||
SELCET用来确定查询的字段,可以使用的有:表的字段,函数,表达式FROM子句来确定查询的表
|
||||
|
||||
SELECT中使用表达式
|
||||
查看每个员工的年薪
|
||||
SELECT ename,sal*12 FROM emp_xwbing;
|
||||
|
||||
@@ -1,22 +1,7 @@
|
||||
SELECT语句
|
||||
SELECT是用来查询数据的语句DQL
|
||||
查询某张表中的所有字段的记录:
|
||||
SELECT * FROM EMP_XWBING;
|
||||
查看指定字段的值:
|
||||
SELECT ename,sal,job FROM EMP_XWBING;
|
||||
|
||||
DQL必须包含的部分是SELECT子句与FROM子句
|
||||
SELCET用来确定查询的字段,可以使用的有:表的字段,函数,表达式FROM子句来确定查询的表
|
||||
|
||||
SELECT中使用表达式
|
||||
查看每个员工的年薪
|
||||
SELECT ename,sal*12 FROM emp_xwbing;
|
||||
|
||||
|
||||
字符串函数
|
||||
1:concat(p1,p2) 连接字符串
|
||||
SELECT concat(ename,sal) FROM emp_xwbing;
|
||||
2:连接字符串简便方式:||,相当与java里的-+号,拼接作用
|
||||
2:连接字符串简便方式:||,相当与java里的+号,拼接作用
|
||||
SELECT ename||':'||sal FROM emp_xwbing;
|
||||
|
||||
LENGTH(p)函数,获取字符串长度
|
||||
@@ -111,6 +96,8 @@ TO_CHAR
|
||||
SELECT TO_CHAR(SYSDATE,'YYYY-MM-DD HH24:MI:SS') FROM DUAL;
|
||||
SELECT TO_DATE('1992-9-1 23:22:11','RR-mm-dd hh24:mi:ss') FROM dual;
|
||||
SELECT TO_CHAR(TO_DATE('99-09-01','RR-MM-DD'),'YYYY-MM-DD') FROM DUAL;
|
||||
SELECT date_format(now(),'%Y-%m-%d %H:%i:%s');//mysql--------------------------------------
|
||||
SELECT str_to_date('2016-01-02 11:11:11','%Y-%m-%d %H:%i:%s');//mysql--------------------------------------
|
||||
|
||||
LAST_DAY(date) 该函数返回给定日期所在月的最后一天
|
||||
查看当月月底?
|
||||
@@ -169,5 +156,4 @@ SELECT ENAME,SAL,NVL2(BOUNS,'有奖金','无奖金') FROM EMP_XWBING;
|
||||
ISNULL(字段) true返回1
|
||||
IF(p1,p2,p3):如果p1是true,返回值为p2;否则返回值则为p3
|
||||
IF(ISNULL(p1),p2,p3) 若p1为null值为p2,p1不为null值为p3
|
||||
SELECT ENAME,SAL,IF(ISNULL(BOUNS),'无奖金','有奖金') FROM EMP_XWBING;
|
||||
|
||||
SELECT ENAME,SAL,IF(ISNULL(BOUNS),'无奖金','有奖金') FROM EMP_XWBING;
|
||||
@@ -59,7 +59,7 @@ SELECT * FROM emp_xwbing ORDER BY field(字段名,'','');//MYSQL----------------
|
||||
|
||||
|
||||
聚合函数又称多行函数:用来统计结果的
|
||||
MAX,MIN 统计最大值,最小值
|
||||
MAX,MIN 统计最大值,最小值,无值为null
|
||||
查看最高工资?
|
||||
SELECT MAX(sal),MIN(sal) FROM emp_xwbing;
|
||||
|
||||
@@ -149,3 +149,4 @@ SELECT d.loc FROM EMP_XWBING E,EMP_XWBING M , dept_xwbing d WHERE E.MGR=M.EMPN
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/11/17 9:26
|
||||
* 作者: xiangwb
|
||||
* 说明: 快递信息
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.xwbing.domain.entity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/11/17 9:22
|
||||
* 作者: xiangwb
|
||||
* 说明: 快递追踪信息
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.xwbing.domain.entity.dto;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/11/20 17:18
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
|
||||
@@ -1,63 +1,65 @@
|
||||
package com.xwbing.domain.entity.model;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 说明: 邮箱属性
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@Data
|
||||
public class EmailModel {
|
||||
public EmailModel(){
|
||||
//默认值
|
||||
}
|
||||
/**
|
||||
* 发送邮件协议名称,默认smtp
|
||||
*/
|
||||
private String protocol;
|
||||
/**
|
||||
* 发送邮箱地址
|
||||
*/
|
||||
private String fromEmail;
|
||||
/**
|
||||
* 邮箱密码
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 接收邮箱
|
||||
*/
|
||||
private String toEmail;
|
||||
/**
|
||||
* 设置发送时间,默认是即时发送
|
||||
*/
|
||||
private Date sendTime;
|
||||
/**
|
||||
* 发送邮件服务器主机
|
||||
*/
|
||||
private String serverHost;
|
||||
/**
|
||||
* 发送邮件服务器端口
|
||||
*/
|
||||
private Integer serverPort;
|
||||
/**
|
||||
* 是否需要身份验证
|
||||
*/
|
||||
private boolean auth;
|
||||
public class EmailModel {
|
||||
public EmailModel() {
|
||||
//默认值
|
||||
}
|
||||
|
||||
/**
|
||||
* 邮件主题
|
||||
*/
|
||||
private String subject;
|
||||
/**
|
||||
* 邮件内容
|
||||
*/
|
||||
private String centent;
|
||||
/**
|
||||
* 邮件附件的文件名
|
||||
*/
|
||||
private String[] attachFileNames;
|
||||
/**
|
||||
* 发送邮件协议名称,默认smtp
|
||||
*/
|
||||
private String protocol;
|
||||
/**
|
||||
* 发送邮箱地址
|
||||
*/
|
||||
private String fromEmail;
|
||||
/**
|
||||
* 邮箱密码
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 接收邮箱
|
||||
*/
|
||||
private String toEmail;
|
||||
/**
|
||||
* 设置发送时间,默认是即时发送
|
||||
*/
|
||||
private Date sendTime;
|
||||
/**
|
||||
* 发送邮件服务器主机
|
||||
*/
|
||||
private String serverHost;
|
||||
/**
|
||||
* 发送邮件服务器端口
|
||||
*/
|
||||
private Integer serverPort;
|
||||
/**
|
||||
* 是否需要身份验证
|
||||
*/
|
||||
private boolean auth;
|
||||
|
||||
/**
|
||||
* 邮件主题
|
||||
*/
|
||||
private String subject;
|
||||
/**
|
||||
* 邮件内容
|
||||
*/
|
||||
private String centent;
|
||||
/**
|
||||
* 邮件附件的文件名
|
||||
*/
|
||||
private String[] attachFileNames;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 说明: 统计属性信息完善程度
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/4/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.Date;
|
||||
* 说明: hibernate validate JSR303校验框架
|
||||
* 各种类型数据校验示例
|
||||
* controller层新增或更新的实体前加@Valid注解
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/17 16:13
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import lombok.Data;
|
||||
|
||||
/**
|
||||
* 说明: 支付宝扫码支付参数
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 17:34
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 说明: 条形码支付结果
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 17:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import lombok.Data;
|
||||
|
||||
/**
|
||||
* 说明: 支付宝接口基础类
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 17:35
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.xwbing.domain.entity.pay.alipay;
|
||||
|
||||
/**
|
||||
* 说明: 支付宝返回状态码
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 17:37
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 说明: 支付宝查询状态
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 17:38
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@@ -15,7 +15,7 @@ public class AliPayQueryResult extends AliPayBaseResult {
|
||||
/**
|
||||
* 交易支付状态
|
||||
*/
|
||||
private String tradeStatus;
|
||||
private String tradeStatus;
|
||||
|
||||
public AliPayQueryResult(boolean success) {
|
||||
this.setSuccess(success);
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import lombok.Data;
|
||||
|
||||
/**
|
||||
* 说明: 支付宝退款参数
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 17:38
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import java.util.Date;
|
||||
|
||||
/**
|
||||
* 说明: 支付宝退款结果
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 17:39
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package com.xwbing.domain.entity.pay.alipay;
|
||||
|
||||
/**
|
||||
* 说明: 支付宝交易状态
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 17:39
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import lombok.Data;
|
||||
|
||||
/**
|
||||
* 说明: 微信扫码支付接口参数
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 17:41
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 说明: 微信扫码支付接口结果
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 17:42
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 说明: 微信支付结果基础类
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 17:42
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 说明: 微信查询状态
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 17:43
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@@ -20,6 +20,7 @@ public class WxQueryResult extends WxBaseResult {
|
||||
* 退款状态
|
||||
*/
|
||||
private String refundStatus;
|
||||
|
||||
public WxQueryResult(boolean success) {
|
||||
this.setSuccess(success);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import lombok.Data;
|
||||
|
||||
/**
|
||||
* 说明: 微信退款参数
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 17:43
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@@ -42,6 +42,7 @@ public class WxRefundParam {
|
||||
this.refundFee = refundFee;
|
||||
this.opUserId = opUserId;
|
||||
}
|
||||
|
||||
public WxRefundParam(String transactionId, String outRefundNo, String opUserId, int totalFee, int refundFee) {
|
||||
this.transactionId = transactionId;
|
||||
this.outRefundNo = outRefundNo;
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 说明: 退款返回结果
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 17:44
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package com.xwbing.domain.entity.pay.wxpay;
|
||||
|
||||
/**
|
||||
* 说明: 微信退款状态
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/12 10:05
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package com.xwbing.domain.entity.pay.wxpay;
|
||||
|
||||
/**
|
||||
* 说明: 微信支付结果状态
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 17:44
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xwbing.domain.entity.rest;
|
||||
|
||||
import com.xwbing.domain.entity.sys.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author xiangwb
|
||||
* @version $Id: FilesUpload.java, v 0.1 2018年06月13日 17:23 wb-xwb402636 Exp $
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class FilesUpload extends BaseEntity {
|
||||
private static final long serialVersionUID = 3284231281346882055L;
|
||||
public static String table = "file_upload";
|
||||
private String name;
|
||||
private String type;
|
||||
private String data;
|
||||
}
|
||||
@@ -4,35 +4,27 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 说明: 基础类
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@Data
|
||||
@MappedSuperclass
|
||||
@ApiModel
|
||||
public class BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = 8901948362657956187L;
|
||||
@Id
|
||||
@Column(length = 50)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private String id;
|
||||
@ApiModelProperty(value = "创建者",hidden = true)
|
||||
@ApiModelProperty(value = "创建者", hidden = true)
|
||||
private String creator;
|
||||
@ApiModelProperty(value = "修改者",hidden = true)
|
||||
@ApiModelProperty(value = "修改者", hidden = true)
|
||||
private String modifier;
|
||||
@ApiModelProperty(value = "创建时间",hidden = true)
|
||||
@Column(name = "create_time")
|
||||
@ApiModelProperty(value = "创建时间", hidden = true)
|
||||
private Date createTime;
|
||||
@ApiModelProperty(value = "修改时间",hidden = true)
|
||||
@Column(name = "modified_time")
|
||||
@ApiModelProperty(value = "修改时间", hidden = true)
|
||||
private Date modifiedTime;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/2/26 10:26
|
||||
* 作者: xiangwb
|
||||
* 说明: 数据字典
|
||||
@@ -16,9 +16,8 @@ import javax.persistence.Entity;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Entity(name = "data_dict")
|
||||
public class DataDictionary extends BaseEntity {
|
||||
public class DataDictionary extends JpaBaseEntity {
|
||||
private static final long serialVersionUID = -3409347240188002427L;
|
||||
public static String table = "data_dict";
|
||||
@ApiModelProperty(value = "编码", required = true)
|
||||
private String code;
|
||||
@ApiModelProperty(value = "名称", required = true)
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.xwbing.domain.entity.sys;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 说明: 基础类
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@Data
|
||||
@ApiModel
|
||||
@MappedSuperclass
|
||||
public class JpaBaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = 2657519817528673800L;
|
||||
@Id
|
||||
@GenericGenerator(name = "idGenerator", strategy = "uuid")
|
||||
@GeneratedValue(generator = "idGenerator")
|
||||
@Column(length = 50)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private String id;
|
||||
@ApiModelProperty(value = "创建者", hidden = true)
|
||||
private String creator;
|
||||
@ApiModelProperty(value = "修改者", hidden = true)
|
||||
private String modifier;
|
||||
@Column(name = "create_time")
|
||||
@ApiModelProperty(value = "创建时间", hidden = true)
|
||||
private Date createTime;
|
||||
@Column(name = "modified_time")
|
||||
@ApiModelProperty(value = "修改时间", hidden = true)
|
||||
private Date modifiedTime;
|
||||
}
|
||||
@@ -4,18 +4,14 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* 说明: 权限
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Entity(name = "sys_authority")
|
||||
public class SysAuthority extends BaseEntity {
|
||||
private static final long serialVersionUID = -6469518352117371987L;
|
||||
public static String table = "sys_authority";
|
||||
@@ -28,7 +24,6 @@ public class SysAuthority extends BaseEntity {
|
||||
@ApiModelProperty(value = "url地址", required = true)
|
||||
private String url;
|
||||
@ApiModelProperty(value = "父ID")
|
||||
@Column(name = "parent_id")
|
||||
private String parentId;
|
||||
@ApiModelProperty(value = "类型(菜单:1|按钮:2)", example = "1", required = true)
|
||||
private Integer type;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.xwbing.domain.entity.sys;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -12,29 +11,27 @@ import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* 说明: 系统配置
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Entity(name = "system_config")
|
||||
@ApiModel//swagger
|
||||
public class SysConfig extends BaseEntity {
|
||||
public class SysConfig extends JpaBaseEntity {
|
||||
private static final long serialVersionUID = -7587016038432881980L;
|
||||
public static String table = "system_config";
|
||||
@ApiModelProperty(value = "配置项的code",example = "email_config",required = true)
|
||||
@ApiModelProperty(value = "配置项的code", example = "email_config", required = true)
|
||||
@NotBlank(message = "配置项的code不能为空")
|
||||
@Length(min = 1, max = 50, message = "code长度为1-50")
|
||||
private String code;
|
||||
@ApiModelProperty(value = "配置项的值",example = "{}",required = true)
|
||||
@ApiModelProperty(value = "配置项的值", example = "{}", required = true)
|
||||
@NotBlank(message = "配置项的value不能为空")
|
||||
private String value;
|
||||
@ApiModelProperty(value = "配置项的描述(名称)",example = "邮箱配置",required = true)
|
||||
@ApiModelProperty(value = "配置项的描述(名称)", example = "邮箱配置", required = true)
|
||||
@NotBlank(message = "配置项的name不能为空")
|
||||
@Length(min = 1, max = 20, message = "value长度为1-20")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "是否启用",example = "Y",required = true)
|
||||
@ApiModelProperty(value = "是否启用", example = "Y", required = true)
|
||||
@NotBlank(message = "是否启用不能为空")
|
||||
@Pattern(regexp = "[Y|N]", message = "是否启用格式为Y|N")
|
||||
private String enable;
|
||||
|
||||
@@ -4,17 +4,14 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* 说明: 角色
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Entity(name = "sys_role")
|
||||
public class SysRole extends BaseEntity {
|
||||
private static final long serialVersionUID = -3048021197170624143L;
|
||||
public static String table = "sys_role";
|
||||
|
||||
@@ -3,29 +3,23 @@ package com.xwbing.domain.entity.sys;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* 说明: 角色权限关系
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Entity(name = "sys_role_authority")
|
||||
public class SysRoleAuthority extends BaseEntity {
|
||||
private static final long serialVersionUID = 1241064470335852429L;
|
||||
public static String table = "sys_role_authority";
|
||||
/**
|
||||
* 角色主键
|
||||
*/
|
||||
@Column(name = "role_id")
|
||||
private String roleId;
|
||||
/**
|
||||
* 权限主键
|
||||
*/
|
||||
@Column(name = "authority_id")
|
||||
private String authorityId;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.xwbing.domain.entity.sys;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -8,50 +7,45 @@ import org.hibernate.validator.constraints.Email;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 说明: 用户
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Entity(name = "sys_user_info")
|
||||
@ApiModel
|
||||
public class SysUser extends BaseEntity {
|
||||
private static final long serialVersionUID = -2447528751353457021L;
|
||||
public static String table = "sys_user_info";
|
||||
@ApiModelProperty(value = "用户名",example = "xxx",required = true)
|
||||
@NotBlank(message = "用户名不能为空")
|
||||
@Length(min = 1, max = 20, message = "用户名长度为1-20")
|
||||
@Column(name = "user_name")
|
||||
@ApiModelProperty(value = "用户名", required = true)
|
||||
private String userName;
|
||||
@ApiModelProperty(value = "姓名",example = "xxx",required = true)
|
||||
@NotBlank(message = "姓名不能为空")
|
||||
@Length(min = 1, max = 5, message = "姓名长度为1-5")
|
||||
@Length(min = 1, max = 20, message = "姓名长度为1-5")
|
||||
@ApiModelProperty(value = "姓名", required = true)
|
||||
private String name;
|
||||
@ApiModelProperty(value = "邮箱",example = "@163.com",required = true)
|
||||
@NotBlank(message = "邮箱不能为空")
|
||||
@Email(message = "邮箱格式有误")
|
||||
@ApiModelProperty(value = "邮箱", example = "@163.com", required = true)
|
||||
private String mail;
|
||||
@ApiModelProperty(value = "性别",example = "1",required = true)
|
||||
@NotBlank(message = "性别不能为空")
|
||||
@Pattern(regexp = "[01]", message = "性别格式为0|1,0代表女,1代表男")
|
||||
@ApiModelProperty(value = "性别(0|1)", example = "1", required = true)
|
||||
private String sex;
|
||||
@ApiModelProperty(value = "盐值",hidden = true)
|
||||
@ApiModelProperty(value = "盐值", hidden = true)
|
||||
private String salt;
|
||||
@ApiModelProperty(value = "密码",hidden = true)
|
||||
@ApiModelProperty(value = "密码", hidden = true)
|
||||
private String password;
|
||||
@ApiModelProperty(value = "是否为管理员",hidden = true)
|
||||
private String admin;
|
||||
@ApiModelProperty(value = "是否为管理员", hidden = true)
|
||||
private String isAdmin;
|
||||
//临时字段
|
||||
@ApiModelProperty(hidden = true)
|
||||
private transient String create;
|
||||
private transient String created;
|
||||
@ApiModelProperty(hidden = true)
|
||||
private transient String modified;
|
||||
@ApiModelProperty(hidden = true)
|
||||
@@ -60,5 +54,4 @@ public class SysUser extends BaseEntity {
|
||||
private transient List<SysAuthority> menus;
|
||||
@ApiModelProperty(hidden = true)
|
||||
private transient List<SysAuthority> buttons;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
package com.xwbing.domain.entity.sys;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/11/7 9:46
|
||||
* 作者: xiangwb
|
||||
* 说明: 用户登录登出信息
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Entity(name = "sys_user_login_in_out")
|
||||
public class SysUserLoginInOut extends BaseEntity {
|
||||
private static final long serialVersionUID = -2719103095945780275L;
|
||||
public static String table = "sys_user_login_in_out";
|
||||
@ApiModelProperty(example = "127.0.0.1", required = true)
|
||||
private String ip;
|
||||
@Column(name = "inout_type")
|
||||
@ApiModelProperty(value = "登录登出类型(登录:1|登出:2)", example = "1", required = true)
|
||||
private int inoutType;
|
||||
@Column(name = "user_id")
|
||||
private String userId;
|
||||
//临时字段
|
||||
@ApiModelProperty(value = "用户名字")
|
||||
private transient String userIdName;
|
||||
@ApiModelProperty(value = "记录时间")
|
||||
private transient String recordTime;
|
||||
private transient String inoutTypeName;
|
||||
// private transient String startDate;
|
||||
// private transient String endDate;
|
||||
private transient String startDate;
|
||||
private transient String endDate;
|
||||
private transient int count;
|
||||
}
|
||||
|
||||
@@ -3,29 +3,23 @@ package com.xwbing.domain.entity.sys;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* 说明: 用户角色关系
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Entity(name = "sys_user_role")
|
||||
public class SysUserRole extends BaseEntity {
|
||||
private static final long serialVersionUID = 7340808603856635810L;
|
||||
public static String table="sys_user_role";
|
||||
public static String table = "sys_user_role";
|
||||
/**
|
||||
* 用户主键
|
||||
*/
|
||||
@Column(name = "user_id")
|
||||
private String userId;
|
||||
private String userId;
|
||||
/**
|
||||
* 角色主键
|
||||
*/
|
||||
@Column(name = "role_id")
|
||||
private String roleId;
|
||||
private String roleId;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/2/26 15:27
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/11/17 9:20
|
||||
* 作者: xiangwb
|
||||
* 说明: 快递信息展示
|
||||
|
||||
@@ -8,14 +8,14 @@ import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/2/26 15:29
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
*/
|
||||
@Data
|
||||
@ApiModel
|
||||
public class ListDataDictionaryVo extends RestMessageVo{
|
||||
public class ListDataDictionaryVo extends RestMessageVo {
|
||||
@ApiModelProperty(value = "返回数据")
|
||||
private List<DataDictionary> data;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/1/18 15:52
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
|
||||
@@ -8,7 +8,7 @@ import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/1/18 15:44
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
|
||||
@@ -8,8 +8,8 @@ import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2018/1/18 15:57
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/1/18 15:52
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xwbing.domain.entity.vo;
|
||||
|
||||
import com.xwbing.domain.entity.sys.SysAuthority;
|
||||
import com.xwbing.util.Pagination;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/1/18 15:52
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
*/
|
||||
@Data
|
||||
@ApiModel
|
||||
public class PageSysAuthorityVo extends RestMessageVo {
|
||||
@ApiModelProperty(value = "返回数据")
|
||||
private Pagination<SysAuthority> data;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xwbing.domain.entity.vo;
|
||||
|
||||
import com.xwbing.domain.entity.sys.SysRole;
|
||||
import com.xwbing.util.Pagination;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/1/18 15:57
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
*/
|
||||
@Data
|
||||
@ApiModel
|
||||
public class PageSysRoleVo extends RestMessageVo {
|
||||
@ApiModelProperty(value = "返回数据")
|
||||
private Pagination<SysRole> data;
|
||||
}
|
||||
+4
-5
@@ -1,21 +1,20 @@
|
||||
package com.xwbing.domain.entity.vo;
|
||||
|
||||
import com.xwbing.domain.entity.sys.SysUserLoginInOut;
|
||||
import com.xwbing.util.Pagination;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/1/18 16:05
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
*/
|
||||
@Data
|
||||
@ApiModel
|
||||
public class ListSysUserLoginInOutVo extends RestMessageVo {
|
||||
public class PageSysUserLoginInOutVo extends RestMessageVo {
|
||||
@ApiModelProperty(value = "返回数据")
|
||||
private List<SysUserLoginInOut> data;
|
||||
private Pagination<SysUserLoginInOut> data;
|
||||
}
|
||||
+4
-5
@@ -1,21 +1,20 @@
|
||||
package com.xwbing.domain.entity.vo;
|
||||
|
||||
import com.xwbing.domain.entity.sys.SysUser;
|
||||
import com.xwbing.util.Pagination;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/1/18 16:01
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
*/
|
||||
@Data
|
||||
@ApiModel
|
||||
public class ListSysUserVo extends RestMessageVo {
|
||||
public class PageSysUserVo extends RestMessageVo {
|
||||
@ApiModelProperty(value = "返回数据")
|
||||
private List<SysUser> data;
|
||||
private Pagination<SysUser> data;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/1/18 15:25
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
|
||||
@@ -2,12 +2,12 @@ package com.xwbing.domain.entity.vo;
|
||||
|
||||
import com.xwbing.domain.entity.sys.SysAuthority;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/11/14 15:43
|
||||
* 作者: xiangwb
|
||||
* 说明: 权限树信息
|
||||
@@ -20,11 +20,8 @@ public class SysAuthVo extends SysAuthority {
|
||||
}
|
||||
|
||||
public SysAuthVo(SysAuthority orig) {
|
||||
try {
|
||||
BeanUtils.copyProperties(this, orig);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
BeanUtils.copyProperties(orig, this);
|
||||
}
|
||||
|
||||
private List<SysAuthVo> children;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/1/18 15:28
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
|
||||
@@ -6,7 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/1/18 15:56
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
|
||||
@@ -6,7 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/1/18 16:00
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.xwbing.domain.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author xiangwb
|
||||
* @version $Id: BaseMapper.java, v 0.1 2018年06月04日 11:05 wb-xwb402636 Exp $
|
||||
*/
|
||||
public interface BaseMapper<M> {
|
||||
int insert(M model);
|
||||
|
||||
int insertBatch(List<M> models);
|
||||
|
||||
int deleteById(String id);
|
||||
|
||||
int deleteByIds(List<String> ids);
|
||||
|
||||
int delete(Map<String, Object> conditions);
|
||||
|
||||
int update(M model);
|
||||
|
||||
int updateBatch(List<M> models);
|
||||
|
||||
M findById(String id);
|
||||
|
||||
List<M> findByIds(List<String> ids);
|
||||
|
||||
List<M> find(Map<String, Object> conditions);
|
||||
|
||||
List<M> findAll();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xwbing.domain.mapper.rest;
|
||||
|
||||
import com.xwbing.domain.entity.rest.FilesUpload;
|
||||
import com.xwbing.domain.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/6/1 21:50
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
*/
|
||||
public interface FilesUploadMapper extends BaseMapper<FilesUpload> {
|
||||
List<FilesUpload> findByName(@Param("name") String name, @Param("type") String type);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.xwbing.domain.mapper.sys;
|
||||
|
||||
import com.xwbing.domain.entity.sys.SysAuthority;
|
||||
import com.xwbing.domain.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/6/1 21:50
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
*/
|
||||
public interface SysAuthorityMapper extends BaseMapper<SysAuthority> {
|
||||
int getMaxSort();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xwbing.domain.mapper.sys;
|
||||
|
||||
import com.xwbing.domain.entity.sys.SysRoleAuthority;
|
||||
import com.xwbing.domain.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/6/1 21:50
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
*/
|
||||
public interface SysRoleAuthorityMapper extends BaseMapper<SysRoleAuthority> {
|
||||
List<SysRoleAuthority> findByRoleId(String roleId);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.xwbing.domain.mapper.sys;
|
||||
|
||||
import com.xwbing.domain.entity.sys.SysRole;
|
||||
import com.xwbing.domain.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/6/1 21:50
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
*/
|
||||
public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xwbing.domain.mapper.sys;
|
||||
|
||||
import com.xwbing.domain.entity.sys.SysUserLoginInOut;
|
||||
import com.xwbing.domain.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/6/1 21:50
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
*/
|
||||
public interface SysUserLoginInOutMapper extends BaseMapper<SysUserLoginInOut> {
|
||||
List<SysUserLoginInOut> findByInoutType(Map<String, Object> map);
|
||||
|
||||
List<SysUserLoginInOut> countByType(Map<String, Object> map);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.xwbing.domain.mapper.sys;
|
||||
|
||||
import com.xwbing.domain.entity.sys.SysUser;
|
||||
import com.xwbing.domain.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/6/1 21:50
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
*/
|
||||
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
SysUser findByUserName(String userName);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xwbing.domain.mapper.sys;
|
||||
|
||||
import com.xwbing.domain.entity.sys.SysUserRole;
|
||||
import com.xwbing.domain.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/6/1 21:50
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
*/
|
||||
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
|
||||
List<SysUserRole> findByUserId(String userId);
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package com.xwbing.domain.repository.sys;
|
||||
package com.xwbing.domain.repository;
|
||||
|
||||
import com.xwbing.domain.entity.sys.DataDictionary;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
@@ -6,7 +6,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/2/26 10:43
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
public interface DataDictionaryRepository extends JpaRepository<DataDictionary, String> {
|
||||
DataDictionary getByCode(String code);
|
||||
|
||||
DataDictionary getByCodeAndEnable(String code,String enable);
|
||||
DataDictionary getByCodeAndEnable(String code, String enable);
|
||||
|
||||
List<DataDictionary> getByParentIdAndEnable(String parentId, String enable);
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package com.xwbing.domain.repository.sys;
|
||||
package com.xwbing.domain.repository;
|
||||
|
||||
import com.xwbing.domain.entity.sys.SysConfig;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
@@ -7,7 +7,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 说明:
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/5 16:44
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package com.xwbing.domain.repository.sys;
|
||||
|
||||
import com.xwbing.domain.entity.sys.SysAuthority;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 说明:
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/5/5 16:44
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
public interface SysAuthorityRepository extends JpaRepository<SysAuthority, String> {
|
||||
SysAuthority getByCode(String code);
|
||||
|
||||
List<SysAuthority> getByEnableOrderBySort(String enable);
|
||||
|
||||
List<SysAuthority> getByParentIdAndEnableOrderBySort(String parentId, String enable);
|
||||
|
||||
List<SysAuthority> getByParentIdOrderBySort(String parentId);
|
||||
|
||||
List<SysAuthority> getByEnableAndIdInOrderBySort(String enable, List<String> ids);
|
||||
|
||||
List<SysAuthority> getByIdInOrderBySort(List<String> ids);
|
||||
|
||||
SysAuthority getBySort(int sort);
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
package com.xwbing.domain.repository.sys;
|
||||
|
||||
import com.xwbing.domain.entity.sys.SysRoleAuthority;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/14 15:13
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
*/
|
||||
public interface SysRoleAuthorityRepository extends JpaRepository<SysRoleAuthority, String> {
|
||||
List<SysRoleAuthority> getByRoleId(String roleId);
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.xwbing.domain.repository.sys;
|
||||
|
||||
import com.xwbing.domain.entity.sys.SysRole;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 说明:
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/5/5 16:44
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
public interface SysRoleRepository extends JpaRepository<SysRole, String> {
|
||||
List<SysRole> getByEnable(String enable);
|
||||
|
||||
SysRole getByCode(String code);
|
||||
|
||||
List<SysRole> getByEnableAndIdIn(String enable, List<String> ids);
|
||||
|
||||
List<SysRole> getByIdIn(List<String> ids);
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
package com.xwbing.domain.repository.sys;
|
||||
|
||||
import com.xwbing.domain.entity.sys.SysUserLoginInOut;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/7 9:58
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
*/
|
||||
public interface SysUserLoginInOutRepository extends JpaRepository<SysUserLoginInOut, String> {
|
||||
List<SysUserLoginInOut> getByInoutType(int inout);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.xwbing.domain.repository.sys;
|
||||
|
||||
import com.xwbing.domain.entity.sys.SysUser;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
/**
|
||||
* 说明:
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/5/5 16:44
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
public interface SysUserRepository extends JpaRepository<SysUser, String> {
|
||||
SysUser getByUserName(String name);
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
package com.xwbing.domain.repository.sys;
|
||||
|
||||
import com.xwbing.domain.entity.sys.SysUserRole;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/14 14:13
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
*/
|
||||
public interface SysUserRoleRepository extends JpaRepository<SysUserRole, String> {
|
||||
List<SysUserRole> getByUserId(String userId);
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
package com.xwbing.druid;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.support.http.StatViewServlet;
|
||||
import com.alibaba.druid.support.http.WebStatFilter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* 说明: 德鲁伊数据源配置。监控地址:druid/index.html
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/12/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(DruidDataSourceModel.class)
|
||||
public class DruidDataSourceConfig {
|
||||
@Resource
|
||||
private DruidDataSourceModel druidDataSourceModel;
|
||||
private final Logger logger = LoggerFactory.getLogger(DruidDataSourceConfig.class);
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public DruidDataSource dataSource() {
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
dataSource.setUrl(druidDataSourceModel.getUrl());
|
||||
dataSource.setDriverClassName(druidDataSourceModel.getDriver());
|
||||
dataSource.setUsername(druidDataSourceModel.getUsername());
|
||||
dataSource.setPassword(druidDataSourceModel.getPassword());
|
||||
dataSource.setInitialSize(druidDataSourceModel.getInitSize());
|
||||
dataSource.setMinIdle(druidDataSourceModel.getMinIdle());
|
||||
dataSource.setMaxActive(druidDataSourceModel.getMaxActive());
|
||||
dataSource.setMaxWait(druidDataSourceModel.getMaxWait());
|
||||
dataSource.setTimeBetweenEvictionRunsMillis(druidDataSourceModel.getTimeBetweenEvictionRunsMillis());
|
||||
dataSource.setMinEvictableIdleTimeMillis(druidDataSourceModel.getMinEvictableIdleTimeMillis());
|
||||
dataSource.setValidationQuery(druidDataSourceModel.getValidationQuery());
|
||||
dataSource.setTestWhileIdle(druidDataSourceModel.isTestWhileIdle());
|
||||
dataSource.setTestOnBorrow(druidDataSourceModel.isTestOnBorrow());
|
||||
dataSource.setTestOnReturn(druidDataSourceModel.isTestOnReturn());
|
||||
dataSource.setPoolPreparedStatements(druidDataSourceModel.isPoolPreparedStatements());
|
||||
dataSource.setMaxPoolPreparedStatementPerConnectionSize(druidDataSourceModel.getMaxPoolPreparedStatementPerConnectionSize());
|
||||
dataSource.setConnectionProperties(druidDataSourceModel.getConnectionProperties());
|
||||
dataSource.setUseGlobalDataSourceStat(druidDataSourceModel.isUseGlobalDataSourceStat());
|
||||
try {
|
||||
dataSource.setFilters(druidDataSourceModel.getFilters());
|
||||
} catch (SQLException e) {
|
||||
logger.error("配置druid过滤器异常");
|
||||
}
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ServletRegistrationBean statViewServlet() {
|
||||
logger.info("注册druid监控信息显示statViewServlet ======================= ");
|
||||
ServletRegistrationBean registration = new ServletRegistrationBean(new StatViewServlet());
|
||||
registration.addUrlMappings("/druid/*");
|
||||
//添加初始化参数:initParams
|
||||
// registration.addInitParameter("allow", "127.0.0.1");//IP白名单(没有配置或者为空,则允许所有访问)
|
||||
// registration.addInitParameter("deny", "172.17.21.232");//IP黑名单(存在共同时,deny优先于allow)
|
||||
registration.addInitParameter("loginUsername", "admin");//用户名
|
||||
registration.addInitParameter("loginPassword", "123456");//密码
|
||||
registration.addInitParameter("resetEnable", "true");//禁用HTML页面上的"Reset All"功能
|
||||
return registration;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean webStatFilter() {
|
||||
logger.info("注册druid监控信息采集webStatFilter ======================= ");
|
||||
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new WebStatFilter());
|
||||
filterRegistrationBean.addUrlPatterns("/*");
|
||||
filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,*.jsp,/druid/*");
|
||||
filterRegistrationBean.addInitParameter("profileEnable", "true");//监控单个url调用的sql列表
|
||||
return filterRegistrationBean;
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
package com.xwbing.druid;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 说明: 德鲁伊数据源参数模型
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/5/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@PropertySource("classpath:druid.properties")
|
||||
@ConfigurationProperties(prefix = "jdbc")
|
||||
public class DruidDataSourceModel {
|
||||
private String url;
|
||||
private String username;
|
||||
private String password;
|
||||
private String driver;
|
||||
/**
|
||||
* 初始连接数
|
||||
*/
|
||||
private int initSize;
|
||||
/**
|
||||
* 最小空闲
|
||||
*/
|
||||
private int minIdle;
|
||||
/**
|
||||
* 最大连接数
|
||||
*/
|
||||
private int maxActive;
|
||||
/**
|
||||
* 连接等待超时时间
|
||||
*/
|
||||
private int maxWait;
|
||||
/**
|
||||
* 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||
*/
|
||||
private int timeBetweenEvictionRunsMillis;
|
||||
/**
|
||||
* 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||
*/
|
||||
private int minEvictableIdleTimeMillis;
|
||||
/**
|
||||
* 用来检测连接是否有效的sql,要求是一个查询语句
|
||||
*/
|
||||
private String validationQuery;
|
||||
/**
|
||||
* 申请连接的时候检测
|
||||
*/
|
||||
private boolean testWhileIdle;
|
||||
/**
|
||||
* 申请连接时执行validationQuery检测连接是否有效,配置为true会降低性能
|
||||
*/
|
||||
private boolean testOnBorrow;
|
||||
/**
|
||||
* 归还连接时执行validationQuery检测连接是否有效,配置为true会降低性能
|
||||
*/
|
||||
private boolean testOnReturn;
|
||||
/**
|
||||
* 打开PSCache,mysql5.5以下的版本中没有PSCache功能,建议关闭掉
|
||||
*/
|
||||
private boolean poolPreparedStatements;
|
||||
/**
|
||||
* 指定每个连接上PSCache的大小
|
||||
*/
|
||||
private int maxPoolPreparedStatementPerConnectionSize;
|
||||
/**
|
||||
* 配置监控统计拦截的filters
|
||||
*/
|
||||
private String filters;
|
||||
/**
|
||||
* 慢SQL记录
|
||||
*/
|
||||
private String connectionProperties;
|
||||
/**
|
||||
* 合并多个DruidDataSource的监控数据
|
||||
*/
|
||||
private boolean useGlobalDataSourceStat;
|
||||
}
|
||||
@@ -2,23 +2,23 @@ package com.xwbing.exception;
|
||||
|
||||
/**
|
||||
* 说明: 自定义业务异常
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/10 16:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
public class BusinessException extends RuntimeException {
|
||||
private static final long serialVersionUID = 7493711492820795133L;
|
||||
private static final long serialVersionUID = 7493711492820795133L;
|
||||
|
||||
public BusinessException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
public BusinessException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public BusinessException(String message) {
|
||||
super(message);
|
||||
}
|
||||
public BusinessException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public BusinessException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
public BusinessException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.xwbing.exception;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/11/22 15:08
|
||||
* 作者: xiangwb
|
||||
* 说明: 工具类异常
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.xwbing.rabbit;
|
||||
|
||||
import lombok.Data;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
@@ -13,11 +12,12 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/4/27 13:42
|
||||
* 作者: xiangwb
|
||||
* 说明: 配置类
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "spring.rabbitmq")
|
||||
@@ -30,7 +30,6 @@ public class RabbitConfig {
|
||||
private int connectionTimeout;
|
||||
private boolean publisherConfirms;
|
||||
private boolean publisherReturns;
|
||||
private final Logger logger = LoggerFactory.getLogger(RabbitConfig.class);
|
||||
|
||||
@Bean
|
||||
public ConnectionFactory connectionFactory() {
|
||||
@@ -60,15 +59,15 @@ public class RabbitConfig {
|
||||
//相应交换机接收后异步回调
|
||||
rabbitTemplate.setConfirmCallback((correlationData, ack, cause) -> {
|
||||
if (ack) {
|
||||
logger.info("交换机接收信息成功,id:{}", correlationData.getId());
|
||||
log.info("交换机接收信息成功,id:{}", correlationData.getId());
|
||||
} else {
|
||||
logger.error("交换机接收信息失败:{}", cause);
|
||||
log.error("交换机接收信息失败:{}", cause);
|
||||
}
|
||||
});
|
||||
//无相应队列与交换机绑定异步回调
|
||||
rabbitTemplate.setReturnCallback((message, replyCode, replyText, exchange, routingKey) -> {
|
||||
String msg = new String(message.getBody());
|
||||
logger.error("消息:{} 发送失败, 应答码:{} 原因:{} 交换机:{} 路由键:{}", msg, replyCode, replyText, exchange, routingKey);
|
||||
log.error("消息:{} 发送失败, 应答码:{} 原因:{} 交换机:{} 路由键:{}", msg, replyCode, replyText, exchange, routingKey);
|
||||
});
|
||||
return rabbitTemplate;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.xwbing.rabbit;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/4/25 14:34
|
||||
* 作者: xiangwb
|
||||
* 说明: Rabbit常量
|
||||
|
||||
@@ -3,8 +3,7 @@ package com.xwbing.rabbit;
|
||||
import com.xwbing.exception.BusinessException;
|
||||
import com.xwbing.service.rest.MailService;
|
||||
import com.xwbing.util.RestMessage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -15,16 +14,16 @@ import static com.xwbing.rabbit.RabbitConstant.EMAIL_QUEUE;
|
||||
import static com.xwbing.rabbit.RabbitConstant.MESSAGE_QUEUE;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/4/25 15:12
|
||||
* 作者: xiangwb
|
||||
* 说明: 消费者
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class Receiver {
|
||||
@Resource
|
||||
private MailService mailService;
|
||||
private final Logger logger = LoggerFactory.getLogger(Receiver.class);
|
||||
|
||||
/**
|
||||
* 处理邮件队列信息
|
||||
@@ -39,7 +38,7 @@ public class Receiver {
|
||||
try {
|
||||
restMessage = mailService.sendSimpleMail(msg[0], "注册成功", content);
|
||||
} catch (BusinessException e) {
|
||||
logger.error("发送邮件给{}失败", msg[0]);
|
||||
log.error("发送邮件给{}失败", msg[0]);
|
||||
}
|
||||
boolean success = restMessage.isSuccess();
|
||||
return MessageFormat.format("成功发送邮件给{0}:{1}", msg[1], success);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.xwbing.rabbit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.amqp.rabbit.support.CorrelationData;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -18,15 +17,11 @@ import java.util.UUID;
|
||||
*/
|
||||
|
||||
//public class Sender implements RabbitTemplate.ConfirmCallback, RabbitTemplate.ReturnCallback {
|
||||
@Slf4j
|
||||
@Component
|
||||
public class Sender {
|
||||
@Resource
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
private final Logger logger = LoggerFactory.getLogger(Sender.class);
|
||||
|
||||
public void sendM(String[] msg) {
|
||||
send(msg, RabbitConstant.CONTROL_EXCHANGE, "aa");
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送信息到email队列
|
||||
@@ -55,12 +50,12 @@ public class Sender {
|
||||
*/
|
||||
private void send(String[] msg, String exchange, String routingKey) {
|
||||
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
||||
logger.info("开始发送消息:{}", Arrays.toString(msg));
|
||||
log.info("开始发送消息:{}", Arrays.toString(msg));
|
||||
//转换并发送消息,且等待消息者返回响应消息。
|
||||
Object response = rabbitTemplate.convertSendAndReceive(exchange, routingKey, msg, correlationId);
|
||||
if (response != null) {
|
||||
logger.info("消费者响应:{}", response.toString());
|
||||
log.info("消费者响应:{}", response.toString());
|
||||
}
|
||||
logger.info("{}消息发送结束", Arrays.toString(msg));
|
||||
log.info("{}消息发送结束", Arrays.toString(msg));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2018/4/25 14:28
|
||||
* 作者: xiangwb
|
||||
* 说明: topic交换机配置
|
||||
|
||||
@@ -9,7 +9,7 @@ import redis.clients.jedis.JedisPoolConfig;
|
||||
|
||||
/**
|
||||
* 说明: redisConfig
|
||||
* 项目名称: boot-module-demo
|
||||
* 项目名称: boot-module-pro
|
||||
* 创建时间: 2017/5/5 16:44
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user