正在显示
4 个修改的文件
包含
14 行增加
和
6 行删除
@@ -89,7 +89,7 @@ func UpdatePositionById(m *Position, col []string, om ...orm.Ormer) (err error) | @@ -89,7 +89,7 @@ func UpdatePositionById(m *Position, col []string, om ...orm.Ormer) (err error) | ||
89 | return | 89 | return |
90 | } | 90 | } |
91 | 91 | ||
92 | -func ExistPositiontName(parentId int64, dname string) bool { | 92 | +func ExistPositiontName(companyid int64, parentId int64, dname string) bool { |
93 | var ( | 93 | var ( |
94 | ok bool | 94 | ok bool |
95 | ) | 95 | ) |
@@ -97,6 +97,7 @@ func ExistPositiontName(parentId int64, dname string) bool { | @@ -97,6 +97,7 @@ func ExistPositiontName(parentId int64, dname string) bool { | ||
97 | ok = o.QueryTable(&Position{}). | 97 | ok = o.QueryTable(&Position{}). |
98 | Filter("name", dname). | 98 | Filter("name", dname). |
99 | Filter("parent_id", parentId). | 99 | Filter("parent_id", parentId). |
100 | + Filter("company_id", companyid). | ||
100 | Filter("delete_at", 0). | 101 | Filter("delete_at", 0). |
101 | Exist() | 102 | Exist() |
102 | return ok | 103 | return ok |
@@ -192,7 +192,7 @@ func GetRoleByPid(pid int64) ([]Role, error) { | @@ -192,7 +192,7 @@ func GetRoleByPid(pid int64) ([]Role, error) { | ||
192 | return roles, err | 192 | return roles, err |
193 | } | 193 | } |
194 | 194 | ||
195 | -func ExistRoleName(rname string, types int8) bool { | 195 | +func ExistRoleName(companyid int64, rname string, types int8) bool { |
196 | var ( | 196 | var ( |
197 | ok bool | 197 | ok bool |
198 | ) | 198 | ) |
@@ -200,6 +200,7 @@ func ExistRoleName(rname string, types int8) bool { | @@ -200,6 +200,7 @@ func ExistRoleName(rname string, types int8) bool { | ||
200 | ok = o.QueryTable(&Role{}). | 200 | ok = o.QueryTable(&Role{}). |
201 | Filter("name", rname). | 201 | Filter("name", rname). |
202 | Filter("types", types). | 202 | Filter("types", types). |
203 | + Filter("company_id", companyid). | ||
203 | Filter("delete_at", 0). | 204 | Filter("delete_at", 0). |
204 | Exist() | 205 | Exist() |
205 | return ok | 206 | return ok |
@@ -28,7 +28,7 @@ func PositionAdd(param protocol.RequestPositionAdd) (*protocol.ResponsePositionI | @@ -28,7 +28,7 @@ func PositionAdd(param protocol.RequestPositionAdd) (*protocol.ResponsePositionI | ||
28 | DeleteAt: time.Unix(0, 0), | 28 | DeleteAt: time.Unix(0, 0), |
29 | ParentId: param.ParentID, | 29 | ParentId: param.ParentID, |
30 | } | 30 | } |
31 | - ok := models.ExistPositiontName(param.ParentID, param.Name) | 31 | + ok := models.ExistPositiontName(param.CompanyID, param.ParentID, param.Name) |
32 | if ok { | 32 | if ok { |
33 | return nil, protocol.NewErrWithMessage("10013") | 33 | return nil, protocol.NewErrWithMessage("10013") |
34 | } | 34 | } |
@@ -106,7 +106,13 @@ func PositionEdit(param protocol.RequestPositionEdit) (*protocol.ResponsePositio | @@ -106,7 +106,13 @@ func PositionEdit(param protocol.RequestPositionEdit) (*protocol.ResponsePositio | ||
106 | log.Error(e.Error()) | 106 | log.Error(e.Error()) |
107 | return nil, protocol.NewErrWithMessage("1", e) | 107 | return nil, protocol.NewErrWithMessage("1", e) |
108 | } | 108 | } |
109 | - positionUpdate.Name = param.Name | 109 | + if positionUpdate.Name != param.Name { |
110 | + ok := models.ExistPositiontName(param.CompanyID, param.ParentID, param.Name) | ||
111 | + if ok { | ||
112 | + return nil, protocol.NewErrWithMessage("10013") | ||
113 | + } | ||
114 | + positionUpdate.Name = param.Name | ||
115 | + } | ||
110 | positionUpdate.UpdateAt = nowTime | 116 | positionUpdate.UpdateAt = nowTime |
111 | err = models.UpdatePositionById(positionUpdate, []string{"Name", "UpdateAt"}) | 117 | err = models.UpdatePositionById(positionUpdate, []string{"Name", "UpdateAt"}) |
112 | if err != nil { | 118 | if err != nil { |
@@ -25,7 +25,7 @@ func RoleAdd(param protocol.RequestRoleAdd) (*protocol.ResponseRoleInfo, error) | @@ -25,7 +25,7 @@ func RoleAdd(param protocol.RequestRoleAdd) (*protocol.ResponseRoleInfo, error) | ||
25 | log.Error(e.Error()) | 25 | log.Error(e.Error()) |
26 | return nil, protocol.NewErrWithMessage("1", e) | 26 | return nil, protocol.NewErrWithMessage("1", e) |
27 | } | 27 | } |
28 | - ok := models.ExistRoleName(param.Name, param.Types) | 28 | + ok := models.ExistRoleName(param.CompanyID, param.Name, param.Types) |
29 | if ok { | 29 | if ok { |
30 | return nil, protocol.NewErrWithMessage("10004") | 30 | return nil, protocol.NewErrWithMessage("10004") |
31 | } | 31 | } |
@@ -113,7 +113,7 @@ func RoleEdit(param protocol.RequestRoleEdit) (*protocol.ResponseRoleInfo, error | @@ -113,7 +113,7 @@ func RoleEdit(param protocol.RequestRoleEdit) (*protocol.ResponseRoleInfo, error | ||
113 | return nil, protocol.NewErrWithMessage("1", e) | 113 | return nil, protocol.NewErrWithMessage("1", e) |
114 | } | 114 | } |
115 | if role.Name != param.Name { | 115 | if role.Name != param.Name { |
116 | - ok := models.ExistRoleName(param.Name, param.Types) | 116 | + ok := models.ExistRoleName(param.CompanyID, param.Name, param.Types) |
117 | if ok { | 117 | if ok { |
118 | return nil, protocol.NewErrWithMessage("10004") | 118 | return nil, protocol.NewErrWithMessage("10004") |
119 | } | 119 | } |
-
请 注册 或 登录 后发表评论