fix
This commit is contained in:
parent
ab472a32f6
commit
f18e1760a2
|
@ -6,7 +6,6 @@ import (
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"fusenapi/utils/chinese_to_pinyin"
|
"fusenapi/utils/chinese_to_pinyin"
|
||||||
"fusenapi/utils/email"
|
"fusenapi/utils/email"
|
||||||
"gorm.io/gorm"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -63,16 +62,16 @@ func (l *CreateLdapUserLogic) CreateLdapUser(req *types.CreateLdapUserReq, r *ht
|
||||||
userDN := fmt.Sprintf("cn=%s,%s", req.Email, l.svcCtx.Config.Ldap.PeopleGroupDN)
|
userDN := fmt.Sprintf("cn=%s,%s", req.Email, l.svcCtx.Config.Ldap.PeopleGroupDN)
|
||||||
//新增一条记录获取递增用户id
|
//新增一条记录获取递增用户id
|
||||||
now := time.Now().UTC()
|
now := time.Now().UTC()
|
||||||
err := l.svcCtx.MysqlConn.Transaction(func(tx *gorm.DB) error {
|
|
||||||
userData := &gmodel.LdapUser{
|
userData := &gmodel.LdapUser{
|
||||||
UserDn: &userDN,
|
UserDn: &userDN,
|
||||||
Ctime: &now,
|
Ctime: &now,
|
||||||
Utime: &now,
|
Utime: &now,
|
||||||
}
|
}
|
||||||
if err := tx.WithContext(l.ctx).Model(&gmodel.LdapUser{}).Create(userData).Error; err != nil {
|
if err := l.svcCtx.AllModels.LdapUser.Create(l.ctx, userData); err != nil {
|
||||||
return err
|
logx.Error(err)
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "新增用户失败!")
|
||||||
}
|
}
|
||||||
return l.svcCtx.Ldap.Create(userDN, map[string][]string{
|
err := l.svcCtx.Ldap.Create(userDN, map[string][]string{
|
||||||
"objectClass": {"person", "organizationalPerson", "inetOrgPerson", "posixAccount", "top", "shadowAccount"}, //固有属性
|
"objectClass": {"person", "organizationalPerson", "inetOrgPerson", "posixAccount", "top", "shadowAccount"}, //固有属性
|
||||||
"shadowLastChange": {"19676"}, //固有属性
|
"shadowLastChange": {"19676"}, //固有属性
|
||||||
"shadowMin": {"0"}, //固有属性
|
"shadowMin": {"0"}, //固有属性
|
||||||
|
@ -93,8 +92,8 @@ func (l *CreateLdapUserLogic) CreateLdapUser(req *types.CreateLdapUserReq, r *ht
|
||||||
"mobile": {req.Mobile}, //手机号
|
"mobile": {req.Mobile}, //手机号
|
||||||
"userPassword": {req.Password}, //密码
|
"userPassword": {req.Password}, //密码
|
||||||
})
|
})
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "添加用户失败,"+err.Error())
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "添加用户失败,"+err.Error())
|
||||||
}
|
}
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "添加用户成功")
|
return resp.SetStatusWithMessage(basic.CodeOK, "添加用户成功")
|
||||||
|
|
|
@ -6,8 +6,6 @@ import (
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"fusenapi/server/ldap-admin/internal/svc"
|
"fusenapi/server/ldap-admin/internal/svc"
|
||||||
|
@ -38,19 +36,12 @@ func (l *DeleteMenuLogic) DeleteMenu(req *types.DeleteMenuReq, userinfo *auth.Us
|
||||||
if req.Id <= 0 {
|
if req.Id <= 0 {
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数id无效")
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数id无效")
|
||||||
}
|
}
|
||||||
err := l.svcCtx.MysqlConn.Transaction(func(tx *gorm.DB) error {
|
|
||||||
menusModel := gmodel.NewLdapMenusModel(tx)
|
|
||||||
status := int64(0)
|
status := int64(0)
|
||||||
now := time.Now().UTC()
|
now := time.Now().UTC()
|
||||||
err := menusModel.Update(l.ctx, req.Id, &gmodel.LdapMenus{
|
err := l.svcCtx.AllModels.LdapMenus.Update(l.ctx, req.Id, &gmodel.LdapMenus{
|
||||||
Status: &status,
|
Status: &status,
|
||||||
Utime: &now,
|
Utime: &now,
|
||||||
})
|
})
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "删除菜单失败")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "删除菜单失败")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user