作者 唐旭辉

bug 修复

... ... @@ -89,7 +89,7 @@ func UpdatePositionById(m *Position, col []string, om ...orm.Ormer) (err error)
return
}
func ExistPositiontName(parentId int64, dname string) bool {
func ExistPositiontName(companyid int64, parentId int64, dname string) bool {
var (
ok bool
)
... ... @@ -97,6 +97,7 @@ func ExistPositiontName(parentId int64, dname string) bool {
ok = o.QueryTable(&Position{}).
Filter("name", dname).
Filter("parent_id", parentId).
Filter("company_id", companyid).
Filter("delete_at", 0).
Exist()
return ok
... ...
... ... @@ -192,7 +192,7 @@ func GetRoleByPid(pid int64) ([]Role, error) {
return roles, err
}
func ExistRoleName(rname string, types int8) bool {
func ExistRoleName(companyid int64, rname string, types int8) bool {
var (
ok bool
)
... ... @@ -200,6 +200,7 @@ func ExistRoleName(rname string, types int8) bool {
ok = o.QueryTable(&Role{}).
Filter("name", rname).
Filter("types", types).
Filter("company_id", companyid).
Filter("delete_at", 0).
Exist()
return ok
... ...
... ... @@ -28,7 +28,7 @@ func PositionAdd(param protocol.RequestPositionAdd) (*protocol.ResponsePositionI
DeleteAt: time.Unix(0, 0),
ParentId: param.ParentID,
}
ok := models.ExistPositiontName(param.ParentID, param.Name)
ok := models.ExistPositiontName(param.CompanyID, param.ParentID, param.Name)
if ok {
return nil, protocol.NewErrWithMessage("10013")
}
... ... @@ -106,7 +106,13 @@ func PositionEdit(param protocol.RequestPositionEdit) (*protocol.ResponsePositio
log.Error(e.Error())
return nil, protocol.NewErrWithMessage("1", e)
}
positionUpdate.Name = param.Name
if positionUpdate.Name != param.Name {
ok := models.ExistPositiontName(param.CompanyID, param.ParentID, param.Name)
if ok {
return nil, protocol.NewErrWithMessage("10013")
}
positionUpdate.Name = param.Name
}
positionUpdate.UpdateAt = nowTime
err = models.UpdatePositionById(positionUpdate, []string{"Name", "UpdateAt"})
if err != nil {
... ...
... ... @@ -25,7 +25,7 @@ func RoleAdd(param protocol.RequestRoleAdd) (*protocol.ResponseRoleInfo, error)
log.Error(e.Error())
return nil, protocol.NewErrWithMessage("1", e)
}
ok := models.ExistRoleName(param.Name, param.Types)
ok := models.ExistRoleName(param.CompanyID, param.Name, param.Types)
if ok {
return nil, protocol.NewErrWithMessage("10004")
}
... ... @@ -113,7 +113,7 @@ func RoleEdit(param protocol.RequestRoleEdit) (*protocol.ResponseRoleInfo, error
return nil, protocol.NewErrWithMessage("1", e)
}
if role.Name != param.Name {
ok := models.ExistRoleName(param.Name, param.Types)
ok := models.ExistRoleName(param.CompanyID, param.Name, param.Types)
if ok {
return nil, protocol.NewErrWithMessage("10004")
}
... ...