From 9bb979dbfb2c4edc31018a83970567f8734c0b61 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期二, 30 七月 2024 11:42:45 +0800
Subject: [PATCH] 单位字典保存前进行重复校验
---
utils/util.go | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/utils/util.go b/utils/util.go
index 61c9c1c..c1b4d52 100644
--- a/utils/util.go
+++ b/utils/util.go
@@ -3,9 +3,31 @@
import (
"github.com/google/uuid"
"strings"
+ "time"
)
func GetUUID() string {
s := uuid.New().String()
return strings.ReplaceAll(s, "-", "")
}
+
+// GetLastMonthPeriod 杩斿洖涓婁釜鏈堢殑鏈堝垵鏃堕棿鍜屾湀鏈椂闂�
+func GetLastMonthPeriod() (time.Time, time.Time) {
+ // 鑾峰彇褰撳墠鏃堕棿
+ now := time.Now()
+
+ // 璁$畻涓婁釜鏈堢殑骞翠唤鍜屾湀浠�
+ lastMonth := now.AddDate(0, -1, 0)
+ lastYear, lastMonthNum, _ := lastMonth.Date()
+
+ // 鑾峰彇涓婁釜鏈堢殑绗竴澶╃殑鏃ユ湡锛堝嵆涓婁釜鏈堟湀鍒濓級
+ firstDayOfLastMonth := time.Date(lastYear, lastMonthNum, 1, 0, 0, 0, 0, now.Location())
+
+ // 鑾峰彇鏈湀绗竴澶╃殑鏃ユ湡锛堝嵆鏈湀鏈堝垵锛�
+ firstDayOfThisMonth := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location())
+
+ // 涓婁釜鏈堟湀鏈椂闂村嵆涓烘湰鏈堟湀鍒濆噺鍘讳竴绉�
+ lastDayOfLastMonth := firstDayOfThisMonth.Add(-time.Second)
+
+ return firstDayOfLastMonth, lastDayOfLastMonth
+}
--
Gitblit v1.8.0