From 5f0170df9787c6f3ff17cc168b3f2e3f511453f6 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期二, 31 十月 2023 20:04:16 +0800
Subject: [PATCH] 支持职级降级的情况
---
model/util.go | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/model/util.go b/model/util.go
index 9e738d9..6c914a8 100644
--- a/model/util.go
+++ b/model/util.go
@@ -2,8 +2,11 @@
import (
"aps_crm/pkg/mysqlx"
+ "aps_crm/proto/code"
"fmt"
"gorm.io/gorm"
+ "strconv"
+ "time"
)
// WithTransaction 锛� var funcs []func(db *gorm.DB) error锛屾妸鐩稿叧鍑芥暟娣诲姞杩涘幓
@@ -26,3 +29,28 @@
err = tx.Commit().Error
return
}
+
+func GetAutoCode(id int, codeStandard *code.CodeStandard) string {
+ autoCode := ""
+ var prefixValue string
+ if codeStandard.AutoRule.PrefixMethod == 2 { // 鏉ユ簮鍗曟嵁
+ prefixValue = ""
+ } else { // 鍥哄畾鍊�
+ prefixValue = codeStandard.AutoRule.PrefixValue
+ }
+ strMaxAutoIncr := strconv.Itoa(id + 1)
+ count := int(codeStandard.AutoRule.AutoLength) - len(strMaxAutoIncr)
+ for i := 0; i < count; i++ {
+ strMaxAutoIncr = "0" + strMaxAutoIncr
+ }
+
+ var suffixValue string
+ if codeStandard.AutoRule.SuffixMethod == 2 { // 骞存湀鏃�+鑷闀�
+ suffixValue = fmt.Sprintf("%v%v", time.Now().Format("20060102"), strMaxAutoIncr)
+ } else { // 鑷闀�
+ suffixValue = strMaxAutoIncr
+ }
+
+ autoCode = prefixValue + suffixValue
+ return autoCode
+}
--
Gitblit v1.8.0