();
+
+ static {
+ simpleDateFormatMap.put(FORMAT_DATE, new SimpleDateFormat(FORMAT_DATE));
+ simpleDateFormatMap.put(FORMAT_HOUR, new SimpleDateFormat(FORMAT_HOUR));
+ simpleDateFormatMap.put(FORMAT_MINUTE, new SimpleDateFormat(FORMAT_MINUTE));
+ simpleDateFormatMap.put(FORMAT_SECOND, new SimpleDateFormat(FORMAT_SECOND));
+ simpleDateFormatMap.put(FORMAT_MILLISECOND, new SimpleDateFormat(FORMAT_MILLISECOND));
+ simpleDateFormatMap.put(FORMAT_NO_DATE, new SimpleDateFormat(FORMAT_NO_DATE));
+ simpleDateFormatMap.put(FORMAT_NO_HOUR, new SimpleDateFormat(FORMAT_NO_HOUR));
+ simpleDateFormatMap.put(FORMAT_NO_MINUTE, new SimpleDateFormat(FORMAT_NO_MINUTE));
+ simpleDateFormatMap.put(FORMAT_NO_SECOND, new SimpleDateFormat(FORMAT_NO_SECOND));
+ simpleDateFormatMap.put(FORMAT_NO_MILLISECOND, new SimpleDateFormat(FORMAT_NO_MILLISECOND));
+ }
+
+ /**
+ * 获取指定时间格式化器
+ *
+ * @param formatStyle 时间格式
+ * @return 时间格式化器
+ */
+ private static SimpleDateFormat getSimpleDateFormat(String formatStyle) {
+ SimpleDateFormat dateFormat = simpleDateFormatMap.get(formatStyle);
+ if (Objects.nonNull(dateFormat)) {
+ return dateFormat;
+ }
+ return new SimpleDateFormat(formatStyle);
+ }
+
+ /**
+ * 将 Date 格式时间转化为指定格式时间
+ *
+ * @param date Date 格式时间
+ * @param formatStyle 转化指定格式(如: yyyy-MM-dd HH:mm:ss)
+ * @return 转化格式时间
+ */
+ public static String format(Date date, String formatStyle) {
+ if (Objects.isNull(date)) {
+ return "";
+ }
+ return getSimpleDateFormat(formatStyle).format(date);
+ }
+
+ /**
+ * 将 Date 格式时间转化为 yyyy-MM-dd 格式时间
+ *
+ * @param date Date 格式时间
+ * @return yyyy-MM-dd 格式时间(如:2022-06-17)
+ */
+ public static String formatDate(Date date) {
+ return format(date, FORMAT_DATE);
+ }
+
+ /**
+ * 将 Date 格式时间转化为 yyyy-MM-dd HH:mm:ss 格式时间
+ *
+ * @param date Date 格式时间
+ * @return yyyy-MM-dd HH:mm:ss 格式时间(如:2022-06-17 16:06:17)
+ */
+ public static String formatDateTime(Date date) {
+ return format(date, FORMAT_SECOND);
+ }
+
+ /**
+ * 将 Date 格式时间转化为 yyyy-MM-dd HH:mm:ss:SSS 格式时间
+ *
+ * @param date Date 格式时间
+ * @return yyyy-MM-dd HH:mm:ss:SSS 格式时间(如:2022-06-17 16:06:17:325)
+ */
+ public static String formatDateTimeStamp(Date date) {
+ return format(date, FORMAT_MILLISECOND);
+ }
+
+ /**
+ * 将 yyyy-MM-dd 格式时间转化为 Date 格式时间
+ *
+ * @param dateString yyyy-MM-dd 格式时间(如:2022-06-17)
+ * @return Date 格式时间
+ */
+ public static Date parseDate(String dateString) {
+ return parse(dateString, FORMAT_DATE);
+ }
+
+ /**
+ * 将 yyyy-MM-dd HH:mm:ss 格式时间转化为 Date 格式时间
+ *
+ * @param dateTimeStr yyyy-MM-dd HH:mm:ss 格式时间(如:2022-06-17 16:06:17)
+ * @return Date 格式时间
+ */
+ public static Date parseDateTime(String dateTimeStr) {
+ return parse(dateTimeStr, FORMAT_SECOND);
+ }
+
+ /**
+ * 将 yyyy-MM-dd HH:mm:ss:SSS 格式时间转化为 Date 格式时间
+ *
+ * @param dateTimeStr yyyy-MM-dd HH:mm:ss:SSS 格式时间(如:2022-06-17 16:06:17)
+ * @return Date 格式时间
+ */
+ public static Date parseDateTimeStamp(String dateTimeStampStr) {
+ return parse(dateTimeStampStr, FORMAT_MILLISECOND);
+ }
+
+ /**
+ * 将字符串格式时间转化为 Date 格式时间
+ *
+ * @param dateString 字符串时间(如:2022-06-17 16:06:17)
+ * @return formatStyle 格式内容
+ * @return Date 格式时间
+ */
+ public static Date parse(String dateString, String formatStyle) {
+ String s = getString(dateString);
+ if (s.isEmpty()) {
+ return null;
+ }
+ try {
+ return getSimpleDateFormat(formatStyle).parse(dateString);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * 获取字符串有效内容
+ *
+ * @param s 字符串
+ * @return 有效内容
+ */
+ private static String getString(String s) {
+ return Objects.isNull(s) ? "" : s.trim();
+ }
+
+ /**
+ * 获取一天的开始时间(即:0 点 0 分 0 秒 0 毫秒)
+ *
+ * @param date 指定时间
+ * @return 当天的开始时间
+ */
+ public static Date getDateStart(Date date) {
+ if (Objects.isNull(date)) {
+ return null;
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ calendar.set(Calendar.MILLISECOND, 0);
+ return calendar.getTime();
+ }
+
+ /**
+ * 获取一天的截止时间(即:23 点 59 分 59 秒 999 毫秒)
+ *
+ * @param date 指定时间
+ * @return 当天的开始时间
+ */
+ public static Date getDateEnd(Date date) {
+ if (Objects.isNull(date)) {
+ return null;
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ calendar.set(Calendar.HOUR_OF_DAY, 23);
+ calendar.set(Calendar.MINUTE, 59);
+ calendar.set(Calendar.SECOND, 59);
+ calendar.set(Calendar.MILLISECOND, 999);
+ return calendar.getTime();
+ }
+
+ /**
+ * 获取日期数字
+ *
+ * @param date 日期
+ * @return 日期数字
+ */
+ public static int getDateNo(Date date) {
+ if (Objects.isNull(date)) {
+ return 0;
+ }
+ return Integer.valueOf(format(date, FORMAT_NO_DATE));
+ }
+
+ /**
+ * 获取日期时间数字(到秒)
+ *
+ * @param date 日期
+ * @return 日期数字
+ */
+ public static long getDateTimeNo(Date date) {
+ if (Objects.isNull(date)) {
+ return 0L;
+ }
+ return Long.valueOf(format(date, FORMAT_NO_SECOND));
+ }
+
+ /**
+ * 获取日期时间数字(到毫秒)
+ *
+ * @param date 日期
+ * @return 日期数字
+ */
+ public static long getDateTimeStampNo(Date date) {
+ if (Objects.isNull(date)) {
+ return 0L;
+ }
+ return Long.valueOf(format(date, FORMAT_NO_MILLISECOND));
+ }
+
+ /**
+ * 获取星期几
+ *
+ * @param date 时间
+ * @return 0(时间为空), 1(周一), 2(周二),3(周三),4(周四),5(周五),6(周六),7(周日)
+ */
+ public static int getWeek(Date date) {
+ if (Objects.isNull(date)) {
+ return 0;
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ return getWeek(calendar);
+ }
+
+ /**
+ * 获取星期几
+ *
+ * @param date 时间
+ * @return 0(时间为空), 1(周一), 2(周二),3(周三),4(周四),5(周五),6(周六),7(周日)
+ */
+ private static int getWeek(Calendar calendar) {
+ switch (calendar.get(Calendar.DAY_OF_WEEK)) {
+ case Calendar.MONDAY:
+ return 1;
+ case Calendar.TUESDAY:
+ return 2;
+ case Calendar.WEDNESDAY:
+ return 3;
+ case Calendar.THURSDAY:
+ return 4;
+ case Calendar.FRIDAY:
+ return 5;
+ case Calendar.SATURDAY:
+ return 6;
+ case Calendar.SUNDAY:
+ return 7;
+ default:
+ return 0;
+ }
+ }
+
+ /**
+ * 获取该日期是今年的第几周(以本年的周一为第1周,详见下面说明)
+ *
+ * 【说明】
+ * 比如 2022-01-01(周六)和 2022-01-02(周日)虽然在 2022 年里,但他们两天则属于 2021 年最后一周,
+ * 那么这两天不会算在 2022 年第 1 周里,此时会返回 0 ;而 2022 年第 1 周将从 2022-01-03(周一) 开始计算。
+ *
+ * @param date 时间
+ * @return -1(时间为空), 0(为上个年的最后一周),其他数字(今年的第几周)
+ */
+ public static int getWeekOfYear(Date date) {
+ if (Objects.isNull(date)) {
+ return -1;
+ }
+ int weeks = getWeekOfYearIgnoreLastYear(date);
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ calendar.set(Calendar.MONTH, Calendar.JANUARY);
+ calendar.set(Calendar.DAY_OF_MONTH, 1);
+ int week = getWeek(calendar);
+ if (week == 1) {
+ return weeks;
+ }
+ return weeks - 1;
+ }
+
+ /**
+ * 获取今年的第几周(以本年的1月1日为第1周第1天)
+ *
+ * @param date 时间
+ * @return -1(时间为空),其他数字(今年的第几周)
+ */
+ public static int getWeekOfYearIgnoreLastYear(Date date) {
+ if (Objects.isNull(date)) {
+ return -1;
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ int days = calendar.get(Calendar.DAY_OF_YEAR);
+ int weeks = days / 7;
+ // 如果是 7 的倍数,则表示恰好是多少周
+ if (days % 7 == 0) {
+ return weeks;
+ }
+ // 如果有余数,则需要再加 1
+ return weeks + 1;
+ }
+
+ /**
+ * 获取时间节点对象
+ *
+ * @param date 时间对象
+ * @return DateNode
+ */
+ public static DateNode getDateNode(Date date) {
+ if (Objects.isNull(date)) {
+ return null;
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ DateNode node = new DateNode();
+ node.setTime(format(date, FORMAT_MILLISECOND));
+ node.setYear(calendar.get(Calendar.YEAR));
+ node.setMonth(calendar.get(Calendar.MONTH) + 1);
+ node.setDay(calendar.get(Calendar.DAY_OF_MONTH));
+ node.setHour(calendar.get(Calendar.HOUR_OF_DAY));
+ node.setMinute(calendar.get(Calendar.MINUTE));
+ node.setSecond(calendar.get(Calendar.SECOND));
+ node.setMillisecond(calendar.get(Calendar.MILLISECOND));
+ node.setWeek(getWeek(calendar));
+ node.setDayOfYear(calendar.get(Calendar.DAY_OF_YEAR));
+ node.setWeekOfYear(getWeekOfYear(date));
+ node.setWeekOfYearIgnoreLastYear(getWeekOfYearIgnoreLastYear(date));
+ node.setMillisecondStamp(date.getTime());
+ node.setSecondStamp(node.getMillisecondStamp() / 1000);
+ return node;
+ }
+
+ /**
+ * 日期变更
+ *
+ * @param date 指定日期
+ * @param field 变更属性(如变更年份,则该值为 Calendar.DAY_OF_YEAR)
+ * @param amount 变更大小(大于 0 时增加,小于 0 时减少)
+ * @return 变更后的日期时间
+ */
+ public static Date add(Date date, int field, int amount) {
+ if (Objects.isNull(date)) {
+ return null;
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ calendar.add(field, amount);
+ return calendar.getTime();
+ }
+
+ /**
+ * 指定日期加减年份
+ *
+ * @param date 指定日期
+ * @param year 变更年份(大于 0 时增加,小于 0 时减少)
+ * @return 变更年份后的日期
+ */
+ public static Date addYear(Date date, int year) {
+ return add(date, Calendar.YEAR, year);
+ }
+
+ /**
+ * 指定日期加减月份
+ *
+ * @param date 指定日期
+ * @param month 变更月份(大于 0 时增加,小于 0 时减少)
+ * @return 变更月份后的日期
+ */
+ public static Date addMonth(Date date, int month) {
+ return add(date, Calendar.MONTH, month);
+ }
+
+ /**
+ * 指定日期加减天数
+ *
+ * @param date 指定日期
+ * @param day 变更天数(大于 0 时增加,小于 0 时减少)
+ * @return 变更天数后的日期
+ */
+ public static Date addDay(Date date, int day) {
+ return add(date, Calendar.DAY_OF_YEAR, day);
+ }
+
+ /**
+ * 指定日期加减星期
+ *
+ * @param date 指定日期
+ * @param week 变更星期数(大于 0 时增加,小于 0 时减少)
+ * @return 变更星期数后的日期
+ */
+ public static Date addWeek(Date date, int week) {
+ return add(date, Calendar.WEEK_OF_YEAR, week);
+ }
+
+ /**
+ * 指定日期加减小时
+ *
+ * @param date 指定日期时间
+ * @param hour 变更小时数(大于 0 时增加,小于 0 时减少)
+ * @return 变更小时数后的日期时间
+ */
+ public static Date addHour(Date date, int hour) {
+ return add(date, Calendar.HOUR_OF_DAY, hour);
+ }
+
+ /**
+ * 指定日期加减分钟
+ *
+ * @param date 指定日期时间
+ * @param minute 变更分钟数(大于 0 时增加,小于 0 时减少)
+ * @return 变更分钟数后的日期时间
+ */
+ public static Date addMinute(Date date, int minute) {
+ return add(date, Calendar.MINUTE, minute);
+ }
+
+ /**
+ * 指定日期加减秒
+ *
+ * @param date 指定日期时间
+ * @param second 变更秒数(大于 0 时增加,小于 0 时减少)
+ * @return 变更秒数后的日期时间
+ */
+ public static Date addSecond(Date date, int second) {
+ return add(date, Calendar.SECOND, second);
+ }
+
+ /**
+ * 指定日期加减秒
+ *
+ * @param date 指定日期时间
+ * @param minute 变更毫秒数(大于 0 时增加,小于 0 时减少)
+ * @return 变更毫秒数后的日期时间
+ */
+ public static Date addMillisecond(Date date, int millisecond) {
+ return add(date, Calendar.MILLISECOND, millisecond);
+ }
+
+ /**
+ * 获取该日期所在周指定星期的日期
+ *
+ * @param date 日期所在时间
+ * @return index 指定星期(1 - 7 分别对应星期一到星期天)
+ */
+ public static Date getWeekDate(Date date, int index) {
+ if (index < WEEK_1_MONDAY || index > WEEK_7_SUNDAY) {
+ return null;
+ }
+ int week = getWeek(date);
+ return addDay(date, index - week);
+ }
+
+ /**
+ * 获取该日期所在周开始日期
+ *
+ * @param date 日期所在时间
+ * @return 所在周开始日期
+ */
+ public static Date getWeekDateStart(Date date) {
+ return getDateStart(getWeekDate(date, WEEK_1_MONDAY));
+ }
+
+ /**
+ * 获取该日期所在周开始日期
+ *
+ * @param date 日期所在时间
+ * @return 所在周开始日期
+ */
+ public static Date getWeekDateEnd(Date date) {
+ return getWeekDateEnd(getWeekDate(date, WEEK_7_SUNDAY));
+ }
+
+ /**
+ * 获取该日期所在周的所有日期(周一到周日)
+ *
+ * @param Date 日期
+ * @return 该日照所在周的所有日期
+ */
+ public static List getWeekDateList(Date date) {
+ if (Objects.isNull(date)) {
+ return Collections.emptyList();
+ }
+ // 获取本周开始时间
+ Date weekFromDate = getWeekDateStart(date);
+ // 获取本周截止时间
+ Date weekeEndDate = getWeekDateEnd(date);
+ return getBetweenDateList(weekFromDate, weekeEndDate, true);
+ }
+
+ /**
+ * 获取该日期所在周的所有日期(周一到周日)
+ *
+ * @param dateString
+ * @return 该日照所在周的所有日期
+ */
+ public static List getWeekDateList(String dateString) {
+ Date date = parseDate(dateString);
+ if (Objects.isNull(date)) {
+ return Collections.emptyList();
+ }
+ return getDateStrList(getWeekDateList(date));
+ }
+
+ /**
+ * 获取该日期所在月的所有日期
+ *
+ * @param dateString
+ * @return 该日照所月的所有日期
+ */
+ public static List getMonthDateList(Date date) {
+ if (Objects.isNull(date)) {
+ return Collections.emptyList();
+ }
+ Date monthDateStart = getMonthDateStart(date);
+ Date monthDateEnd = getMonthDateEnd(date);
+ return getBetweenDateList(monthDateStart, monthDateEnd, true);
+ }
+
+ /**
+ * 获取该日期所在月的所有日期
+ *
+ * @param dateString
+ * @return 该日照所月的所有日期
+ */
+ public static List getMonthDateList(String dateString) {
+ Date date = parseDate(dateString);
+ if (Objects.isNull(date)) {
+ return Collections.emptyList();
+ }
+ return getDateStrList(getMonthDateList(date));
+ }
+
+ /**
+ * 获取本日期所在月第一天
+ *
+ * @param date 日期
+ * @return 本日期所在月第一天
+ */
+ public static Date getMonthDateStart(Date date) {
+ if (Objects.isNull(date)) {
+ return null;
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ calendar.set(Calendar.DAY_OF_MONTH, 1);
+ return getDateStart(calendar.getTime());
+ }
+
+ /**
+ * 获取本日期所在月最后一天
+ *
+ * @param date 日期
+ * @return 本日期所在月最后一天
+ */
+ public static Date getMonthDateEnd(Date date) {
+ if (Objects.isNull(date)) {
+ return null;
+ }
+ Date monthDateStart = getMonthDateStart(date);
+ Date nextMonthDateStart = getMonthDateStart(addMonth(monthDateStart, 1));
+ return getDateEnd(addDay(nextMonthDateStart, -1));
+ }
+
+ /**
+ * 获取两个日期相差的天数(以日期为单位计算,不以24小时制计算,详见下面说明)
+ *
+ * 【说明】比如 2022-06-17 23:00:00 和 2022-06-17 01:00:00,两者虽然只相差 2 个小时,但也算相差 1 天
+ *
+ * @param date1 日期1
+ * @param date2 日期2
+ * @return 相差天数(若返回 -1,则至少有一个日期存在为空,此时不能进行比较)
+ */
+ public static int countBetweenDays(Date date1, Date date2) {
+ if (Objects.isNull(date1) || Objects.isNull(date2)) {
+ return -1;
+ }
+ // 获取两个日期 0 点 0 时 0 分 0 秒 0 毫秒时的时间戳(毫秒级)
+ long t1 = getDateStart(date1).getTime();
+ long t2 = getDateStart(date2).getTime();
+ // 相差天数 = 相差的毫秒数 / 一天的毫秒数
+ return (int) (Math.abs(t1 - t2) / DAY_MILLISECONDS);
+ }
+
+ /**
+ * 获取两个日期之间的所有日期
+ *
+ * @param date1 日期1
+ * @param date2 日期2
+ * @return 两个日期之间的所有日期的开始时间
+ */
+ public static List getBetweenDateList(Date date1, Date date2) {
+ return getBetweenDateList(date1, date2, false);
+ }
+
+ /**
+ * 获取两个日期之间的所有日期
+ *
+ * @param date1 日期1
+ * @param date2 日期2
+ * @return 两个日期之间的所有日期的开始时间
+ */
+ public static List getBetweenDateList(Date date1, Date date2, boolean isContainParams) {
+ if (Objects.isNull(date1) || Objects.isNull(date2)) {
+ return Collections.emptyList();
+ }
+ // 确定前后日期
+ Date fromDate = date1;
+ Date toDate = date2;
+ if (date2.before(date1)) {
+ fromDate = date2;
+ toDate = date1;
+ }
+ // 获取两个日期每天的开始时间
+ Date from = getDateStart(fromDate);
+ Date to = getDateStart(toDate);
+ // 获取日期,开始循环
+ List dates = new ArrayList();
+ if (isContainParams) {
+ dates.add(from);
+ }
+ Date date = from;
+ boolean isBefore = true;
+ while (isBefore) {
+ date = addDay(date, 1);
+ isBefore = date.before(to);
+ if (isBefore) {
+ dates.add(getDateStart(date));
+ }
+ }
+ if (isContainParams) {
+ dates.add(to);
+ }
+ return dates;
+ }
+
+ /**
+ * 获取两个日期之间的所有日期
+ *
+ * @param dateString1 日期1(如:2022-06-20)
+ * @param dateString2 日期2(如:2022-07-15)
+ * @return 两个日期之间的所有日期(不包含参数日期)
+ */
+ public static List getBetweenDateList(String dateString1, String dateString2) {
+ return getBetweenDateList(dateString1, dateString2, false);
+ }
+
+ /**
+ * 获取两个日期之间的所有日期
+ *
+ * @param dateString1 日期1(如:2022-06-20)
+ * @param dateString2 日期2(如:2022-07-15)
+ * @param isContainParams 是否包含参数的两个日期
+ * @return 两个日期之间的所有日期的开始时间
+ */
+ public static List getBetweenDateList(String dateString1, String dateString2, boolean isContainParams) {
+ Date date1 = parseDate(dateString1);
+ Date date2 = parseDate(dateString2);
+ List dates = getBetweenDateList(date1, date2, isContainParams);
+ return getDateStrList(dates);
+ }
+
+ /**
+ * List 转 List
+ *
+ * @param dates 日期集合
+ * @return 日期字符串集合
+ */
+ public static List getDateStrList(List dates) {
+ if (dates.isEmpty()) {
+ return Collections.emptyList();
+ }
+ List dateList = new ArrayList();
+ for (Date date : dates) {
+ dateList.add(formatDate(date));
+ }
+ return dateList;
+ }
+
+ static class DateNode {
+ /**
+ * 年
+ */
+ private int year;
+ /**
+ * 月
+ */
+ private int month;
+ /**
+ * 日
+ */
+ private int day;
+ /**
+ * 时
+ */
+ private int hour;
+ /**
+ * 分
+ */
+ private int minute;
+ /**
+ * 秒
+ */
+ private int second;
+ /**
+ * 毫秒
+ */
+ private int millisecond;
+ /**
+ * 星期几( 1 - 7 对应周一到周日)
+ */
+ private int week;
+ /**
+ * 当年第几天
+ */
+ private int dayOfYear;
+ /**
+ * 当年第几周(本年周 1 为第 1 周,0 则表示属于去年最后一周)
+ */
+ private int weekOfYear;
+ /**
+ * 当年第几周(本年周 1 为第 1 周,0 则表示属于去年最后一周)
+ */
+ private int weekOfYearIgnoreLastYear;
+ /**
+ * 时间戳(秒级)
+ */
+ private long secondStamp;
+ /**
+ * 时间戳(毫秒级)
+ */
+ private long millisecondStamp;
+ /**
+ * 显示时间
+ */
+ private String time;
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public int getMonth() {
+ return month;
+ }
+
+ public void setMonth(int month) {
+ this.month = month;
+ }
+
+ public int getDay() {
+ return day;
+ }
+
+ public void setDay(int day) {
+ this.day = day;
+ }
+
+ public int getHour() {
+ return hour;
+ }
+
+ public void setHour(int hour) {
+ this.hour = hour;
+ }
+
+ public int getMinute() {
+ return minute;
+ }
+
+ public void setMinute(int minute) {
+ this.minute = minute;
+ }
+
+ public int getSecond() {
+ return second;
+ }
+
+ public void setSecond(int second) {
+ this.second = second;
+ }
+
+ public int getMillisecond() {
+ return millisecond;
+ }
+
+ public void setMillisecond(int millisecond) {
+ this.millisecond = millisecond;
+ }
+
+ public int getWeek() {
+ return week;
+ }
+
+ public void setWeek(int week) {
+ this.week = week;
+ }
+
+ public int getDayOfYear() {
+ return dayOfYear;
+ }
+
+ public void setDayOfYear(int dayOfYear) {
+ this.dayOfYear = dayOfYear;
+ }
+
+ public int getWeekOfYear() {
+ return weekOfYear;
+ }
+
+ public void setWeekOfYear(int weekOfYear) {
+ this.weekOfYear = weekOfYear;
+ }
+
+ public int getWeekOfYearIgnoreLastYear() {
+ return weekOfYearIgnoreLastYear;
+ }
+
+ public void setWeekOfYearIgnoreLastYear(int weekOfYearIgnoreLastYear) {
+ this.weekOfYearIgnoreLastYear = weekOfYearIgnoreLastYear;
+ }
+
+ public long getSecondStamp() {
+ return secondStamp;
+ }
+
+ public void setSecondStamp(long secondStamp) {
+ this.secondStamp = secondStamp;
+ }
+
+ public long getMillisecondStamp() {
+ return millisecondStamp;
+ }
+
+ public void setMillisecondStamp(long millisecondStamp) {
+ this.millisecondStamp = millisecondStamp;
+ }
+
+ public String getTime() {
+ return time;
+ }
+
+ public void setTime(String time) {
+ this.time = time;
+ }
+
+ }
+}
diff --git a/src/main/java/com/light/util/FxDataUtil.java b/src/main/java/com/light/util/FxDataUtil.java
index 80917778db59809b890f295617f5d0bc70c815bf..7fb351e66c13352774ae7ccc2d73f248cfd172f4 100644
--- a/src/main/java/com/light/util/FxDataUtil.java
+++ b/src/main/java/com/light/util/FxDataUtil.java
@@ -1,6 +1,6 @@
package com.light.util;
-import atlantafx.base.theme.Theme;
+import atlantafx.base.theme.*;
import com.light.model.GitProject;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
@@ -27,6 +27,9 @@ public final class FxDataUtil {
public static final AtomicInteger UPDATE_NUMBER = new AtomicInteger(0);
public static final SimpleIntegerProperty UPDATE_PROPERTY = new SimpleIntegerProperty(UPDATE_NUMBER.intValue());
+ /**
+ * git项目集合
+ */
public static final ObservableList GIT_PROJECT_OBSERVABLE_LIST = FXCollections.observableArrayList();
/**
@@ -38,4 +41,9 @@ public final class FxDataUtil {
* 所有主题
*/
public static final List THEME_LIST = new ArrayList<>(7);
+
+ /**
+ * 历史通知集合
+ */
+ public static final ObservableList HISTORY_NOTICE_LIST = FXCollections.observableArrayList();
}
diff --git a/src/main/java/com/light/util/H2PoolUtils.java b/src/main/java/com/light/util/H2PoolUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..1dd4e2e8f91da469c05273ccb44ccea9b091e0d0
--- /dev/null
+++ b/src/main/java/com/light/util/H2PoolUtils.java
@@ -0,0 +1,312 @@
+package com.light.util;
+
+import com.light.model.GitNotice;
+import com.light.model.GitProject;
+import javafx.beans.property.SimpleBooleanProperty;
+import javafx.beans.property.SimpleDoubleProperty;
+import javafx.beans.property.SimpleIntegerProperty;
+import javafx.beans.property.SimpleStringProperty;
+import org.apache.commons.lang3.StringUtils;
+import org.h2.jdbcx.JdbcConnectionPool;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * @Author: wangss
+ * @CreateTime: 2023-05-19 22:36
+ * @Description: H2连接池
+ */
+public class H2PoolUtils {
+
+ public static final Logger LOGGER = LoggerFactory.getLogger(H2PoolUtils.class);
+ private static JdbcConnectionPool connectionPool = null;
+
+ private static final String DB_DRIVER;
+ private static final String DB_URL;
+ private static final String DB_URL_PREFIX;
+ private static final String DB_URL_SUFFIX;
+ private static final String DB_USERNAME;
+ private static final String DB_PASSWORD;
+ private static final int DB_POOL_MAXIDLE;
+ private static final int DB_POOL_MAXACTIVE;
+
+ static {
+ Properties properties = new Properties();
+ try {
+ properties.load(H2PoolUtils.class.getResourceAsStream("/db.properties"));
+ DB_DRIVER = properties.getProperty("jdbc.driver", "org.h2.Driver");
+ DB_URL_PREFIX = properties.getProperty("jdbc.url.prefix", "jdbc:h2:file:");
+ DB_URL_SUFFIX = properties.getProperty("jdbc.url.suffix", "/.h2/git-db;AUTO_SERVER=TRUE");
+ DB_USERNAME = properties.getProperty("jdbc.username", "git");
+ DB_PASSWORD = properties.getProperty("jdbc.password", "git@123");
+ DB_POOL_MAXIDLE = Integer.parseInt(properties.getProperty("jdbc.pool.maxIdle", "5"));
+ DB_POOL_MAXACTIVE = Integer.parseInt(properties.getProperty("jdbc.pool.maxActive", "20"));
+ DB_URL = DB_URL_PREFIX + System.getProperty("user.home") + DB_URL_SUFFIX;
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * 获取链接
+ *
+ * @return
+ * @throws SQLException
+ */
+ public static Connection getConnection() throws SQLException {
+ if (connectionPool == null) {
+ createConnectionPool();
+ }
+ return connectionPool.getConnection();
+ }
+
+ /**
+ * 创建连接池
+ */
+ private static void createConnectionPool() {
+ connectionPool = JdbcConnectionPool.create(DB_URL, DB_USERNAME, DB_PASSWORD);
+ connectionPool.setMaxConnections(DB_POOL_MAXACTIVE);
+ LOGGER.info("h2 连接池初始化成功");
+ }
+
+ /**
+ * 关闭连接池
+ */
+ public static void closeConnectionPool() {
+ if (null != connectionPool) {
+ connectionPool.dispose();
+ LOGGER.info("h2 连接池关闭");
+ }
+ }
+
+ /**
+ * 创建项目所需表
+ *
+ * @throws SQLException
+ */
+ public static void createTable() throws SQLException {
+ Connection conn = getConnection();
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("drop table git_project_info if exists");
+ stmt.executeUpdate("drop table git_project_dict if exists");
+ stmt.executeUpdate("drop table git_project_notice_history if exists");
+ // 初始化项目信息表
+ String createGitProjectInfoTable = """
+ create table git_project_info
+ (
+ id INT PRIMARY KEY AUTO_INCREMENT,
+ name VARCHAR(100) NOT NULL comment '项目名称',
+ author varchar(100) comment '作者',
+ branch VARCHAR(100) comment '当前分支',
+ remote varchar(255) comment '仓库地址',
+ local varchar(255) comment '本地地址',
+ createtime varchar(20) comment '创建时间',
+ updatetime varchar(20) comment '更新时间',
+ description VARCHAR(1000) comment '描述',
+ remark VARCHAR(1000) comment '备注',
+ level int default 0 comment '学习等级'
+ )
+ """;
+ stmt.executeUpdate(createGitProjectInfoTable);
+ LOGGER.info("h2 项目信息表创建成功");
+
+ // 初始化字典表
+ String createGitProjectDictTable = """
+ create table git_project_dict
+ (
+ id int primary key auto_increment,
+ label varchar(100) comment '标签',
+ label_value varchar(100) comment '值',
+ description VARCHAR(255) comment '描述',
+ createtime varchar(20) comment '创建时间',
+ updatetime varchar(20) comment '更新时间'
+ )
+ """;
+ stmt.executeUpdate(createGitProjectDictTable);
+ LOGGER.info("h2 字典表创建成功");
+
+ // 初始化通知历史表
+ String createGitProjectNoticeHistoryTable = """
+ create table git_project_notice_history
+ (
+ id int primary key auto_increment,
+ notice varchar(1000) comment '通知信息',
+ level varchar(10) comment '通知等级',
+ createtime varchar(20) comment '创建时间'
+ )
+ """;
+ stmt.executeUpdate(createGitProjectNoticeHistoryTable);
+ LOGGER.info("h2 通知消息历史表创建成功");
+ }
+
+ /**
+ * 初始化字典表数据
+ *
+ * @throws SQLException
+ */
+ public static void initGitProjectDictData() throws SQLException {
+ Date currentDate = new Date();
+ Connection conn = getConnection();
+ Statement stmt = conn.createStatement();
+ String sql = "insert into git_project_dict(label, label_value, description, createtime, updatetime) values('GIT_DB_INIT','1','项目数据库初始化标识:0 未初始化,1 初始化', " +
+ "'" + DateUtils.formatDateTime(currentDate) + "', '" + DateUtils.formatDateTime(currentDate) + "')";
+ stmt.addBatch(sql);
+ String sql2 = "insert into git_project_dict(label, label_value, description, createtime, updatetime) values('GIT_CURRENT_THEME','Primer Light','项目当前主题', " +
+ "'" + DateUtils.formatDateTime(currentDate) + "', '" + DateUtils.formatDateTime(currentDate) + "')";
+ stmt.addBatch(sql2);
+ stmt.executeBatch();
+ LOGGER.info("h2 字典表数据初始化成功");
+ }
+
+ public static String queryDictByLabel(String label, String defaultValue) {
+ String value = defaultValue;
+ try (Connection conn = getConnection();) {
+ String sql = "select * from git_project_dict where label = ?";
+ PreparedStatement statement = conn.prepareStatement(sql);
+ statement.setString(1, label);
+ ResultSet resultSet = statement.executeQuery();
+ while (resultSet.next()) {
+ value = resultSet.getString("label_value");
+ }
+ } catch (SQLException e) {
+ LOGGER.error("通过 {} 查询数据异常:{}", label, e.getMessage());
+ }
+ LOGGER.info("通过 {} 查询数据结果:{}", label, value);
+ return value;
+ }
+
+ public static void updateDictData(String label, String value) {
+ try (Connection conn = getConnection()) {
+ String sql = "update git_project_dict set label_value = ? where label = ?";
+ PreparedStatement statement = conn.prepareStatement(sql);
+ statement.setString(1, value);
+ statement.setString(2, label);
+ statement.executeUpdate();
+ } catch (SQLException ignored) {
+ LOGGER.error("通过 {} 更新数据为 {} 失败:{}", label, value, ignored.getMessage());
+ }
+ LOGGER.info("通过 {} 更新数据为 {} 成功", label, value);
+ }
+
+ public static void insertNoticeHistory(String notice, String level) {
+ try (Connection conn = getConnection()) {
+ String sql = "INSERT INTO git_project_notice_history(notice, level, createtime) values(?,?,?)";
+ PreparedStatement statement = conn.prepareStatement(sql);
+ statement.setString(1, notice);
+ statement.setString(2, level);
+ statement.setString(3, DateUtils.formatDateTime(new Date()));
+ statement.executeUpdate();
+ } catch (SQLException e) {
+ LOGGER.error("记录 {} 数据异常:{}", notice, e.getMessage());
+ }
+ LOGGER.info("记录 {} 数据成功", notice);
+ }
+
+ public static List queryNoticeHistory(String level, boolean sort, int limit) {
+ List result = new ArrayList<>();
+ try (Connection conn = getConnection()) {
+ String sql = "select * from git_project_notice_history " + (StringUtils.isBlank(level) ? "" : "where level = ?") + " order by createtime " + (sort ? "" : "desc") + " limit ? ";
+ PreparedStatement statement = conn.prepareStatement(sql);
+ if (StringUtils.isBlank(level)) {
+ statement.setInt(1, limit);
+ } else {
+ statement.setString(1, level);
+ statement.setInt(2, limit);
+ }
+ statement.executeQuery();
+
+ ResultSet resultSet = statement.getResultSet();
+ while (resultSet.next()) {
+ GitNotice gitNotice = new GitNotice(resultSet.getInt("id"),
+ resultSet.getString("label"), resultSet.getString("label_value"),
+ resultSet.getString("createtime"));
+ result.add(gitNotice);
+ }
+ } catch (SQLException e) {
+ LOGGER.error("通过 {} 获取通知数据异常:{}", level, e.getMessage());
+ }
+ return result;
+ }
+
+ public static List queryNoticeHistory(boolean sort, int limit) {
+ return queryNoticeHistory(null, sort, limit);
+ }
+
+ public static void insertProjectInfo(GitProject project) {
+ try (Connection conn = getConnection()) {
+ String sql = """
+ INSERT INTO git_project_info(name, author,
+ branch, remote, local, createtime, updatetime
+ ) values(?,?,?,?,?,?,?)
+ """;
+ PreparedStatement statement = conn.prepareStatement(sql);
+ statement.setString(1, project.name().get());
+ statement.setString(2, project.author().get());
+ statement.setString(3, project.branch().get());
+ statement.setString(4, project.remote());
+ statement.setString(5, project.local().get());
+ Date date = new Date();
+ statement.setString(6, DateUtils.formatDateTime(date));
+ statement.setString(7, DateUtils.formatDateTime(date));
+ statement.executeUpdate();
+ } catch (SQLException e) {
+ LOGGER.error("项目信息保存异常:{}", e.getMessage());
+ }
+ LOGGER.info("项目信息 {} 保存成功", project);
+ }
+
+ public static void queryGitProjects() {
+ try (Connection conn = getConnection()) {
+ String sql = "select * from git_project_info order by id";
+ PreparedStatement statement = conn.prepareStatement(sql);
+ statement.executeQuery();
+
+ ResultSet resultSet = statement.getResultSet();
+ while (resultSet.next()) {
+ GitProject gitProject = new GitProject(
+ new SimpleStringProperty(resultSet.getInt("id") + ""),
+ new SimpleStringProperty(resultSet.getString("name")),
+ new SimpleStringProperty(resultSet.getString("author")),
+ new SimpleStringProperty(resultSet.getString("branch")),
+ resultSet.getString("createtime"),
+ new SimpleStringProperty(resultSet.getString("updatetime")),
+ resultSet.getString("remote"),
+ new SimpleStringProperty(resultSet.getString("local")),
+ new SimpleStringProperty(resultSet.getString("description")),
+ new SimpleStringProperty(resultSet.getString("remark")),
+ new SimpleIntegerProperty(resultSet.getInt("level")),
+ new SimpleDoubleProperty(0.0),
+ new SimpleBooleanProperty(false)
+ );
+ gitProject.addSelectedListener();
+ FxDataUtil.GIT_PROJECT_OBSERVABLE_LIST.add(gitProject);
+ }
+ } catch (SQLException e) {
+ LOGGER.error("获取所有项目信息异常:{}", e.getMessage());
+ }
+ }
+
+ public static void updateGitProject(GitProject project) {
+ try (Connection conn = getConnection()) {
+ String sql = "update git_project_info set branch = ? ,updatetime = ?, local = ?, description = ?, remark = ?, level = ? where id = ?";
+ PreparedStatement statement = conn.prepareStatement(sql);
+ statement.setString(1, project.branch().get());
+ statement.setString(2, project.updateTime().get());
+ statement.setString(3, project.local().get());
+ statement.setString(4, project.description().get());
+ statement.setString(5, project.remark().get());
+ statement.setInt(6, project.level().get());
+ statement.setInt(7, Integer.parseInt(project.id().get()));
+ statement.executeUpdate();
+ } catch (SQLException e) {
+ LOGGER.error("更新项目信息异常:{}", e.getMessage());
+ }
+ }
+}
diff --git a/src/main/java/com/light/util/H2Utils.java b/src/main/java/com/light/util/H2Utils.java
deleted file mode 100644
index 186e4c22cf1359e05f25b96eabb51cdeeb893661..0000000000000000000000000000000000000000
--- a/src/main/java/com/light/util/H2Utils.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package com.light.util;
-
-public class H2Utils {
-}
diff --git a/src/main/java/com/light/view/ManagerView.java b/src/main/java/com/light/view/ManagerView.java
index c509130f31d9a789b0eb943ed77d8671aac8bfcc..32dd5d6d3c817c8b7794e27199dfeababc919aaa 100644
--- a/src/main/java/com/light/view/ManagerView.java
+++ b/src/main/java/com/light/view/ManagerView.java
@@ -8,12 +8,10 @@ import com.light.component.OperationTableCell;
import com.light.component.TooltipTableRow;
import com.light.enums.Level;
import com.light.model.GitProject;
+import com.light.thread.AsyncTask;
import com.light.util.FxDataUtil;
+import com.light.util.H2PoolUtils;
import com.light.util.NoticeUtils;
-import javafx.beans.property.SimpleBooleanProperty;
-import javafx.beans.property.SimpleDoubleProperty;
-import javafx.beans.property.SimpleIntegerProperty;
-import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
@@ -54,8 +52,14 @@ public class ManagerView extends StackPane {
public ManagerView() {
this.getChildren().add(vBox);
initialize();
- initData();
initEvent();
+ // 异步初始化数据
+ AsyncTask.runOnce(new AsyncTask("init_project_data", "初始化项目数据") {
+ @Override
+ protected void handler() throws Exception {
+ initData();
+ }
+ });
}
public void initialize() {
@@ -65,14 +69,13 @@ public class ManagerView extends StackPane {
addLocalButton.setMnemonicParsing(true);
updateButton.setMnemonicParsing(true);
hBox.getChildren().addAll(searchField, addLocalButton, updateButton);
- hBox.setPadding(new Insets(5, 0, 0, 0));
HBox.setHgrow(searchField, Priority.ALWAYS);
// 初始化表格
initTable();
vBox.getChildren().addAll(hBox, tableView);
- vBox.setPadding(new Insets(0, 1, 0, 1));
+ vBox.setPadding(new Insets(5, 2, 5, 2));
VBox.setVgrow(tableView, Priority.ALWAYS);
}
@@ -87,25 +90,25 @@ public class ManagerView extends StackPane {
select.setMinWidth(40d);
var id = new TableColumn("序号");
- id.setCellValueFactory(c -> new SimpleStringProperty(c.getValue().id()));
+ id.setCellValueFactory(c -> c.getValue().id());
id.setPrefWidth(50d);
id.setMaxWidth(50d);
id.setMinWidth(50d);
var warehouse = new TableColumn("仓库");
- warehouse.setCellValueFactory(c -> new SimpleStringProperty(c.getValue().name()));
+ warehouse.setCellValueFactory(c -> c.getValue().name());
var author = new TableColumn("作者");
- author.setCellValueFactory(c -> new SimpleStringProperty(c.getValue().author()));
+ author.setCellValueFactory(c -> c.getValue().author());
var branch = new TableColumn("分支");
branch.setSortable(false);
branch.setCellFactory(ChoiceBoxTableCell.forTableColumn("master", "develop"));
- branch.setCellValueFactory(c -> new SimpleStringProperty(c.getValue().branch()));
+ branch.setCellValueFactory(c -> c.getValue().branch());
var level = new TableColumn("学习等级");
level.setCellFactory(LevelTableCell.forTableColumn());
- level.setCellValueFactory(c -> new SimpleIntegerProperty(c.getValue().level()).asObject());
+ level.setCellValueFactory(c -> c.getValue().level().asObject());
var process = new TableColumn("更新进度");
process.setSortable(false);
@@ -115,7 +118,7 @@ public class ManagerView extends StackPane {
var operation = new TableColumn("操作");
operation.setSortable(false);
operation.setCellFactory(OperationTableCell.forTableColumn());
- operation.setCellValueFactory(c -> new SimpleStringProperty(c.getValue().id()));
+ operation.setCellValueFactory(c -> c.getValue().id());
operation.setPrefWidth(120d);
operation.setMaxWidth(120d);
operation.setMinWidth(120d);
@@ -133,12 +136,7 @@ public class ManagerView extends StackPane {
public void initData() {
// TODO 查H2数据库获取数据
- for (int i = 0; i < 100; i++) {
- GitProject gitProject = new GitProject(i + "", "g" + i + "it", "project", "develop", "2023-09-30",
- "2023-09-30", "https://gitee.com/code-poison/git-manager-client-fx.git", "D:\\workspace\\workspace-dev\\git-manager-client-fx", "测试一下效果", "", i % 5, new SimpleDoubleProperty(0.0), new SimpleBooleanProperty(false));
- gitProject.addSelectedListener();
- FxDataUtil.GIT_PROJECT_OBSERVABLE_LIST.add(gitProject);
- }
+ H2PoolUtils.queryGitProjects();
}
public void initEvent() {
@@ -210,10 +208,10 @@ public class ManagerView extends StackPane {
List list;
if (FxDataUtil.GIT_PROJECT_OBSERVABLE_LIST.size() > 10000) {
list = FxDataUtil.GIT_PROJECT_OBSERVABLE_LIST.
- parallelStream().filter(param -> param.name().contains(text) || param.author().contains(text)).toList();
+ parallelStream().filter(param -> param.name().get().contains(text) || param.author().get().contains(text)).toList();
} else {
list = FxDataUtil.GIT_PROJECT_OBSERVABLE_LIST.
- stream().filter(param -> param.name().contains(text) || param.author().contains(text)).toList();
+ stream().filter(param -> param.name().get().contains(text) || param.author().get().contains(text)).toList();
}
tableView.setItems(FXCollections.observableList(list));
} else {
diff --git a/src/main/java/com/light/view/NotificationView.java b/src/main/java/com/light/view/NotificationView.java
new file mode 100644
index 0000000000000000000000000000000000000000..16e16b218886ed38e8cac18ff4e8246dc024e194
--- /dev/null
+++ b/src/main/java/com/light/view/NotificationView.java
@@ -0,0 +1,13 @@
+package com.light.view;
+
+import com.light.util.FxDataUtil;
+import javafx.collections.ListChangeListener;
+import javafx.scene.control.Label;
+
+public class NotificationView extends Label {
+ public NotificationView() {
+ super(FxDataUtil.HISTORY_NOTICE_LIST.size() + "");
+ this.getStyleClass().add("notice-label");
+ FxDataUtil.HISTORY_NOTICE_LIST.addListener((ListChangeListener) c -> setText(FxDataUtil.HISTORY_NOTICE_LIST.size() + ""));
+ }
+}
diff --git a/src/main/resources/css/menu.css b/src/main/resources/css/menu.css
index 3abb4969cc598d3315ac5b74a8e5986fe9bf11cb..fca6ccaf4e3c09f643103fe624e3c06f2b3a476a 100644
--- a/src/main/resources/css/menu.css
+++ b/src/main/resources/css/menu.css
@@ -24,20 +24,31 @@
.nav-item > .icon-label > .ikonli-font-icon {
-fx-icon-size: 20px;
- -fx-icon-color: derive(-cf-text-color, 30%);
+ -fx-icon-color: derive(-color-fg-default, 30%);
}
.nav-item > .name-label {
-fx-font-size: 14px;
-fx-pref-height: 30px;
-fx-font-weight: bolder;
- -fx-text-fill: derive(-cf-text-color, 30%);
+ -fx-text-fill: derive(-color-fg-default, 30%);
+}
+
+.nav-item > .notice-label {
+ -fx-font-size: 14px;
+ -fx-pref-height: 30px;
+ -fx-alignment: center;
+ -fx-text-fill: derive(-color-fg-default, 30%);
}
.nav-item:hover > .name-label {
-fx-text-fill: -cf-primary-color;
}
+.nav-item:hover > .notice-label {
+ -fx-text-fill: -cf-primary-color;
+}
+
.nav-item:hover > .icon-label > .ikonli-font-icon {
-fx-icon-color: -cf-primary-color;
}
@@ -108,23 +119,36 @@
-fx-icon-color: -cf-success-color;
}
-.cf-message{
+.cf-message {
-fx-alignment: center-left;
-fx-min-height: 40px;
-fx-graphic-text-gap: 8px;
-fx-padding: 0 10px;
-fx-background-color: rgb(168, 70, 70);
- -fx-background-radius:3px;
+ -fx-background-radius: 3px;
-fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.2), 10.0, 0, 0, 0);
-fx-text-fill: -cf-text-color;
-fx-font-size: 14px;
-fx-wrap-text: true;
}
-.cf-message > .ikonli-font-icon{
+
+.cf-message > .ikonli-font-icon {
-fx-icon-color: -cf-primary-color;
-fx-icon-size: 18px;
}
-.cf-message.success > .ikonli-font-icon{-fx-icon-color: -cf-success-color;}
-.cf-message.info > .ikonli-font-icon{-fx-icon-color: -cf-info-color;}
-.cf-message.warn > .ikonli-font-icon{-fx-icon-color: -cf-warn-color;}
-.cf-message.danger > .ikonli-font-icon{-fx-icon-color: -cf-danger-color;}
\ No newline at end of file
+
+.cf-message.success > .ikonli-font-icon {
+ -fx-icon-color: -cf-success-color;
+}
+
+.cf-message.info > .ikonli-font-icon {
+ -fx-icon-color: -cf-info-color;
+}
+
+.cf-message.warn > .ikonli-font-icon {
+ -fx-icon-color: -cf-warn-color;
+}
+
+.cf-message.danger > .ikonli-font-icon {
+ -fx-icon-color: -cf-danger-color;
+}
\ No newline at end of file
diff --git a/src/main/resources/css/root.css b/src/main/resources/css/root.css
index 26a77258e82096501f642387e3d91f6d9cc4deaa..1e94ac24f857a8aa3643fff6bb68da02ece271f4 100644
--- a/src/main/resources/css/root.css
+++ b/src/main/resources/css/root.css
@@ -5,10 +5,10 @@
-fx-min-height: 40px;
-fx-graphic-text-gap: 8px;
-fx-padding: 0 10px;
- -fx-background-color: rgb(255, 255, 255);
+ -fx-background-color: -color-bg-default;
-fx-background-radius: 3px;
-fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.2), 10.0, 0, 0, 0);
- -fx-text-fill: -cf-text-color;
+ -fx-text-fill: -color-fg-default;
-fx-font-size: 14px;
-fx-wrap-text: true;
}
diff --git a/src/main/resources/db.properties b/src/main/resources/db.properties
new file mode 100644
index 0000000000000000000000000000000000000000..907a0be903c75b4c00f99c2dd81c28e1fc9b8816
--- /dev/null
+++ b/src/main/resources/db.properties
@@ -0,0 +1,9 @@
+#h2 database settings
+jdbc.driver=org.h2.Driver
+jdbc.url.prefix=jdbc:h2:file:
+jdbc.url.suffix=/.h2/git-db;AUTO_SERVER=TRUE
+jdbc.username=git
+jdbc.password=git@123
+#connection pool settings
+jdbc.pool.maxIdle=5
+jdbc.pool.maxActive=20
\ No newline at end of file
diff --git a/src/main/resources/db/schema.sql b/src/main/resources/db/schema.sql
new file mode 100644
index 0000000000000000000000000000000000000000..af9387d4ecd765a7fa7a6187b8ce0fb572a0bbde
--- /dev/null
+++ b/src/main/resources/db/schema.sql
@@ -0,0 +1,38 @@
+/*开源项目信息*/
+create table git_project_info
+(
+ id INT PRIMARY KEY AUTO_INCREMENT,
+ name VARCHAR(100) NOT NULL comment '项目名称',
+ author varchar(100) comment '作者',
+ branch VARCHAR(100) comment '当前分支',
+ remote varchar(255) comment '仓库地址',
+ local varchar(255) comment '本地地址',
+ createtime varchar(20) comment '创建时间',
+ updatetime varchar(20) comment '更新时间',
+ description VARCHAR(1000) comment '描述',
+ remark VARCHAR(1000) comment '备注',
+ level int default 0 comment '学习等级'
+);
+
+/*字典表*/
+create table git_project_dict
+(
+ id int primary key auto_increment,
+ label varchar(100) comment '标签',
+ label_value varchar(100) comment '值',
+ description VARCHAR(255) comment '描述',
+ createtime varchar(20) comment '创建时间',
+ updatetime varchar(20) comment '更新时间'
+);
+
+insert into git_project_dict(label, label_value, description) values('GIT_DB_INIT','1','项目数据库初始化标识:0 未初始化,1 初始化');
+insert into git_project_dict(label, label_value, description) values('GIT_CURRENT_THEME','Primer Light','项目当前主题');
+
+/*通知历史记录表*/
+create table git_project_notice_history
+(
+ id int primary key auto_increment,
+ notice varchar(1000) comment '通知信息',
+ level varchar(10) comment '通知等级',
+ createtime varchar(20) comment '创建时间'
+);
\ No newline at end of file