You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package ServiceLoginPerson
import (
"dsSso/Dao/DaoSysLoginPerson"
"dsSso/Utils/CommonUtil"
"dsSso/Utils/MobileUtil"
"fmt"
)
/**
功能:验证用户名和密码是否正确
作者:黄海
时间2020-02-05
*/
func Login(username string, password string, ip string) (bool, string, string, string) {
//异常处理
defer func() {
if err := recover(); err != nil {
fmt.Printf("%s\n", err)
}
}()
var personId string
var err error
//1、判断是不是身份证件号是不是邮箱是不是联系电话
if CommonUtil.IsEmail(username) {
personId, err = DaoSysLoginPerson.GetPersonIdByEmail(username)
if err != nil || len(personId) == 0 {
return false, "", "", ""
}
} else if CommonUtil.IsIdCard(username) {
personId, err = DaoSysLoginPerson.GetPersonIdByIdCard(username)
if err != nil || len(personId) == 0 {
return false, "", "", ""
}
} else if MobileUtil.VerifyMobileFormat(username) {
personId, err = DaoSysLoginPerson.GetPersonIdByTel(username)
if err != nil || len(personId) == 0 {
return false, "", "", ""
}
}
//根据person_id换取统一的登录名
username, err = DaoSysLoginPerson.GetLoginNameByPersonId(personId)
if err != nil || len(username) == 0 {
return false, "", "", ""
}
//调用dao层的方法,组合成service方法层
result, identityId, personId, personName := DaoSysLoginPerson.Login(username, password, ip)
return result, identityId, personId, personName
}