修改了分享嘛
This commit is contained in:
parent
14f4314982
commit
38ce98fada
@ -205,7 +205,7 @@ func (r *QuestionQaService) AddQuestionQa(req requests.AddQuestionQa) (bool, err
|
||||
|
||||
// 生成分享链接
|
||||
questionQaData := make(map[string]interface{})
|
||||
questionQaData["qa_share_id"] = utils.HashString(fmt.Sprintf("%d", questionQa.QaId))
|
||||
questionQaData["qa_share_id"] = utils.GenerateUniqueCode()
|
||||
err = questionQaDao.EditQuestionQaById(tx, questionQa.QaId, questionQaData)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
|
||||
10
utils/aes.go
10
utils/aes.go
@ -7,7 +7,10 @@ import (
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
mathRand "math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Encrypt 加密函数
|
||||
@ -88,3 +91,10 @@ func hashKey(key string) []byte {
|
||||
hash := sha256.Sum256([]byte(key))
|
||||
return hash[:]
|
||||
}
|
||||
|
||||
// GenerateUniqueCode 生成6位数唯一码
|
||||
func GenerateUniqueCode() string {
|
||||
mathRand.Seed(time.Now().UnixNano())
|
||||
code := fmt.Sprintf("%06d", mathRand.Intn(999999))
|
||||
return code
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user