service.go
1.0 KB
package domainService
import (
"crypto/sha1"
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_basic"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)
func AdvancedSettingInit() {
domain.RegisModel(domain.NewModel(domain.UserModel{}))
}
//GetInitPassword 获取公司初始化密码
func GetInitPassword(operator domain.Operator) (string, string, error) {
var password string
alliedCreationBasic := allied_creation_basic.NewHttplibAlliedCreationBasic(operator)
reqResult, err := alliedCreationBasic.SystemSettingGet(allied_creation_basic.ReqSystemSettingGet{
domain.InitPasswordSettingKey,
})
if err != nil {
log.Logger.Error(err.Error())
return "", "", err
}
if len(reqResult.Value) == 0 {
return "", "", fmt.Errorf("初始化密码不能为空 ")
}
password = fmt.Sprintf("%x", sha1.Sum([]byte(reqResult.Value)))
return password, reqResult.Value, err
}