Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/oppmg into dev
正在显示
9 个修改的文件
包含
39 行增加
和
29 行删除
@@ -63,11 +63,8 @@ func (c *CompanyController) DepartmentAdd() { | @@ -63,11 +63,8 @@ func (c *CompanyController) DepartmentAdd() { | ||
63 | msg = protocol.BadRequestParam("10043") | 63 | msg = protocol.BadRequestParam("10043") |
64 | return | 64 | return |
65 | } | 65 | } |
66 | + | ||
66 | if param.ParentID <= 0 { | 67 | if param.ParentID <= 0 { |
67 | - msg = protocol.BadRequestParam("10042") | ||
68 | - return | ||
69 | - } | ||
70 | - if param.ParentID == 0 { | ||
71 | //部门必定有上级部门 ,至少是公司一级 | 68 | //部门必定有上级部门 ,至少是公司一级 |
72 | msg = protocol.BadRequestParam("10042") | 69 | msg = protocol.BadRequestParam("10042") |
73 | return | 70 | return |
@@ -106,6 +103,11 @@ func (c *CompanyController) DepartmentUpdate() { | @@ -106,6 +103,11 @@ func (c *CompanyController) DepartmentUpdate() { | ||
106 | msg = protocol.BadRequestParam("10043") | 103 | msg = protocol.BadRequestParam("10043") |
107 | return | 104 | return |
108 | } | 105 | } |
106 | + if param.ParentID <= 0 { | ||
107 | + //部门必定有上级部门 ,至少是公司一级 | ||
108 | + msg = protocol.BadRequestParam("10042") | ||
109 | + return | ||
110 | + } | ||
109 | param.CompanyID = c.GetCompanyId() | 111 | param.CompanyID = c.GetCompanyId() |
110 | if param.ID <= 0 { | 112 | if param.ID <= 0 { |
111 | log.Error(" param.ID <= 0 ") | 113 | log.Error(" param.ID <= 0 ") |
@@ -399,7 +401,7 @@ func (c *CompanyController) UserList() { | @@ -399,7 +401,7 @@ func (c *CompanyController) UserList() { | ||
399 | msg = protocol.BadRequestParam("1") | 401 | msg = protocol.BadRequestParam("1") |
400 | return | 402 | return |
401 | } | 403 | } |
402 | - | 404 | + param.NickName = strings.TrimSpace(param.NickName) |
403 | param.Companyid = c.GetCompanyId() | 405 | param.Companyid = c.GetCompanyId() |
404 | result, err := servecompany.UserList(param) | 406 | result, err := servecompany.UserList(param) |
405 | msg = protocol.NewPageDataResponse(result, err) | 407 | msg = protocol.NewPageDataResponse(result, err) |
@@ -640,6 +642,10 @@ func (c *CompanyController) CurrentCompanyEdit() { | @@ -640,6 +642,10 @@ func (c *CompanyController) CurrentCompanyEdit() { | ||
640 | msg = protocol.BadRequestParam("1") | 642 | msg = protocol.BadRequestParam("1") |
641 | return | 643 | return |
642 | } | 644 | } |
645 | + if len(param.Logo) == 0 { | ||
646 | + msg = protocol.NewReturnResponse(nil, nil) | ||
647 | + return | ||
648 | + } | ||
643 | companyid := c.GetCompanyId() | 649 | companyid := c.GetCompanyId() |
644 | err := servecompany.CompanyInfoEdit(companyid, param.Logo) | 650 | err := servecompany.CompanyInfoEdit(companyid, param.Logo) |
645 | msg = protocol.NewReturnResponse(nil, err) | 651 | msg = protocol.NewReturnResponse(nil, err) |
@@ -153,6 +153,7 @@ type TemplateOperateCategoryRequest struct { | @@ -153,6 +153,7 @@ type TemplateOperateCategoryRequest struct { | ||
153 | Icon string `json:"icon"` | 153 | Icon string `json:"icon"` |
154 | } | 154 | } |
155 | type TemplateOperateCategoryResponse struct { | 155 | type TemplateOperateCategoryResponse struct { |
156 | + Id int `json:"id"` | ||
156 | } | 157 | } |
157 | 158 | ||
158 | /*TemplateGet */ | 159 | /*TemplateGet */ |
@@ -43,7 +43,7 @@ var errmessge ErrorMap = map[string]string{ | @@ -43,7 +43,7 @@ var errmessge ErrorMap = map[string]string{ | ||
43 | // "10040": "注册用户失败", | 43 | // "10040": "注册用户失败", |
44 | //部门相关 | 44 | //部门相关 |
45 | "10041": "无效的主管设置", | 45 | "10041": "无效的主管设置", |
46 | - "10042": "无效的上级部门", | 46 | + "10042": "上级部门不能选择当前部门及其子部门", |
47 | "10043": "部门名称限制不超过20个字符", | 47 | "10043": "部门名称限制不超过20个字符", |
48 | "10044": "部门名称必填", | 48 | "10044": "部门名称必填", |
49 | "10045": "同一级部门名称不允许重复", | 49 | "10045": "同一级部门名称不允许重复", |
@@ -121,16 +121,6 @@ func init() { | @@ -121,16 +121,6 @@ func init() { | ||
121 | beego.AddNamespace(nsV1) | 121 | beego.AddNamespace(nsV1) |
122 | beego.AddNamespace(nsAuth) | 122 | beego.AddNamespace(nsAuth) |
123 | beego.AddNamespace(nsUcenter) | 123 | beego.AddNamespace(nsUcenter) |
124 | - // nsTest := beego.NewNamespace("/test", | ||
125 | - // beego.NSCond(func(ctx *context.Context) bool { | ||
126 | - // if beego.BConfig.RunMode != "prod" { | ||
127 | - // return true | ||
128 | - // } | ||
129 | - // return false | ||
130 | - // }), | ||
131 | - // beego.NSRouter("/te", &controllers.RbacController{}, "get:GetRoleMenuAll"), | ||
132 | - // ) | ||
133 | - // beego.AddNamespace(nsTest) | ||
134 | beego.SetStaticPath("/log", beego.AppConfig.String("log_filename")) | 124 | beego.SetStaticPath("/log", beego.AppConfig.String("log_filename")) |
135 | beego.SetStaticPath("/file/opp", beego.AppConfig.String("file_save_path")) | 125 | beego.SetStaticPath("/file/opp", beego.AppConfig.String("file_save_path")) |
136 | beego.SetStaticPath("/static", "./static") | 126 | beego.SetStaticPath("/static", "./static") |
@@ -442,6 +442,7 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe | @@ -442,6 +442,7 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe | ||
442 | log.Error(err.Error()) | 442 | log.Error(err.Error()) |
443 | return | 443 | return |
444 | } | 444 | } |
445 | + rsp.Id = chanceType.Id | ||
445 | return | 446 | return |
446 | } | 447 | } |
447 | if len([]rune(request.Code)) > 6 { | 448 | if len([]rune(request.Code)) > 6 { |
@@ -463,6 +464,7 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe | @@ -463,6 +464,7 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe | ||
463 | if _, err = models.AddChanceType(chanceType); err != nil { | 464 | if _, err = models.AddChanceType(chanceType); err != nil { |
464 | log.Error(err.Error()) | 465 | log.Error(err.Error()) |
465 | } | 466 | } |
467 | + rsp.Id = chanceType.Id | ||
466 | return | 468 | return |
467 | } | 469 | } |
468 | 470 |
@@ -171,11 +171,7 @@ func DepartmentEdit(param protocol.RequestDepartmentEdit) error { | @@ -171,11 +171,7 @@ func DepartmentEdit(param protocol.RequestDepartmentEdit) error { | ||
171 | log.Error(e.Error()) | 171 | log.Error(e.Error()) |
172 | return protocol.NewErrWithMessage("1", e) | 172 | return protocol.NewErrWithMessage("1", e) |
173 | } | 173 | } |
174 | - r := newparent.Relation | ||
175 | - rs := strings.Split(r, "/") | ||
176 | - if len(rs) >= 10 { //层级不能超过10级 | ||
177 | - return protocol.NewErrWithMessage("10046") | ||
178 | - } | 174 | + |
179 | } | 175 | } |
180 | //更新部门关系数据 | 176 | //更新部门关系数据 |
181 | err = departmentRelationUpdate(departUpdate, newparent) | 177 | err = departmentRelationUpdate(departUpdate, newparent) |
@@ -234,8 +230,14 @@ func departmentRelationUpdate(departUpdate *models.Department, newparent *models | @@ -234,8 +230,14 @@ func departmentRelationUpdate(departUpdate *models.Department, newparent *models | ||
234 | log.Error(e.Error()) | 230 | log.Error(e.Error()) |
235 | return protocol.NewErrWithMessage("10042") | 231 | return protocol.NewErrWithMessage("10042") |
236 | } | 232 | } |
237 | - //重建关系树 | 233 | + //确认层级深度 |
238 | s := strings.TrimPrefix(departSubset[i].Relation, oldRelation) | 234 | s := strings.TrimPrefix(departSubset[i].Relation, oldRelation) |
235 | + n := strings.Split(s, "/") | ||
236 | + if len(n) >= 0 { | ||
237 | + o.Rollback() | ||
238 | + return protocol.NewErrWithMessage("10046") | ||
239 | + } | ||
240 | + //重建关系树 | ||
239 | departSubset[i].Relation = strings.TrimSpace(fmt.Sprintf("%s%s", newRelation, s)) | 241 | departSubset[i].Relation = strings.TrimSpace(fmt.Sprintf("%s%s", newRelation, s)) |
240 | err = utils.ExecuteSQLWithOrmer(o, dataSql2, departSubset[i].Relation, departSubset[i].Id) | 242 | err = utils.ExecuteSQLWithOrmer(o, dataSql2, departSubset[i].Relation, departSubset[i].Id) |
241 | if err != nil { | 243 | if err != nil { |
@@ -162,9 +162,6 @@ func PositionEdit(param protocol.RequestPositionEdit) (*protocol.ResponsePositio | @@ -162,9 +162,6 @@ func PositionEdit(param protocol.RequestPositionEdit) (*protocol.ResponsePositio | ||
162 | 162 | ||
163 | //positionRelationUpdate 处理部门上级发生变化的情况 | 163 | //positionRelationUpdate 处理部门上级发生变化的情况 |
164 | func positionRelationUpdate(positionUpdate *models.Position, newparent *models.Position) error { | 164 | func positionRelationUpdate(positionUpdate *models.Position, newparent *models.Position) error { |
165 | - if newparent == nil { | ||
166 | - return nil | ||
167 | - } | ||
168 | const ( | 165 | const ( |
169 | //获取某个部门的下级部门 锁数据 select ... for update | 166 | //获取某个部门的下级部门 锁数据 select ... for update |
170 | dataSql0 string = `SELECT id,relation FROM position WHERE relation LIKE ? AND delete_at = 0 FOR UPDATE` | 167 | dataSql0 string = `SELECT id,relation FROM position WHERE relation LIKE ? AND delete_at = 0 FOR UPDATE` |
@@ -178,8 +175,15 @@ func positionRelationUpdate(positionUpdate *models.Position, newparent *models.P | @@ -178,8 +175,15 @@ func positionRelationUpdate(positionUpdate *models.Position, newparent *models.P | ||
178 | err error | 175 | err error |
179 | oldRelation string = positionUpdate.Relation | 176 | oldRelation string = positionUpdate.Relation |
180 | relationLike string = oldRelation + "%" | 177 | relationLike string = oldRelation + "%" |
181 | - newRelation string = fmt.Sprintf("%s/%d", newparent.Relation, positionUpdate.Id) | 178 | + newRelation string |
182 | ) | 179 | ) |
180 | + if newparent == nil { | ||
181 | + //修改节点为顶层节点的情况 | ||
182 | + newparent = &models.Position{} | ||
183 | + newRelation = fmt.Sprintf("%d", positionUpdate.Id) | ||
184 | + } else { | ||
185 | + newRelation = fmt.Sprintf("%s/%d", newparent.Relation, positionUpdate.Id) | ||
186 | + } | ||
183 | o := orm.NewOrm() | 187 | o := orm.NewOrm() |
184 | o.Begin() | 188 | o.Begin() |
185 | //修改部门的parent_id | 189 | //修改部门的parent_id |
@@ -209,6 +213,11 @@ func positionRelationUpdate(positionUpdate *models.Position, newparent *models.P | @@ -209,6 +213,11 @@ func positionRelationUpdate(positionUpdate *models.Position, newparent *models.P | ||
209 | } | 213 | } |
210 | //重建关系树 | 214 | //重建关系树 |
211 | s := strings.TrimPrefix(positionSubset[i].Relation, oldRelation) | 215 | s := strings.TrimPrefix(positionSubset[i].Relation, oldRelation) |
216 | + rs := strings.Split(s, "/") | ||
217 | + if len(rs) >= 10 { //层级不能超过10级 | ||
218 | + o.Rollback() | ||
219 | + return protocol.NewErrWithMessage("10012") | ||
220 | + } | ||
212 | positionSubset[i].Relation = strings.TrimSpace(fmt.Sprintf("%s%s", newRelation, s)) | 221 | positionSubset[i].Relation = strings.TrimSpace(fmt.Sprintf("%s%s", newRelation, s)) |
213 | err = utils.ExecuteSQLWithOrmer(o, dataSql2, positionSubset[i].Relation, positionSubset[i].Id) | 222 | err = utils.ExecuteSQLWithOrmer(o, dataSql2, positionSubset[i].Relation, positionSubset[i].Id) |
214 | if err != nil { | 223 | if err != nil { |
@@ -165,7 +165,7 @@ func existCompanyUser(companyid int64, phone string) error { | @@ -165,7 +165,7 @@ func existCompanyUser(companyid int64, phone string) error { | ||
165 | 165 | ||
166 | ok := models.ExistUserCompany(userdata.Id, companyid) | 166 | ok := models.ExistUserCompany(userdata.Id, companyid) |
167 | if ok { | 167 | if ok { |
168 | - protocol.NewErrWithMessage("10039") | 168 | + return protocol.NewErrWithMessage("10039") |
169 | } | 169 | } |
170 | return nil | 170 | return nil |
171 | } | 171 | } |
@@ -80,7 +80,7 @@ func RoleDelete(param protocol.RequestRoleDelete) error { | @@ -80,7 +80,7 @@ func RoleDelete(param protocol.RequestRoleDelete) error { | ||
80 | return protocol.NewErrWithMessage("1") | 80 | return protocol.NewErrWithMessage("1") |
81 | } | 81 | } |
82 | if cnt > 0 { | 82 | if cnt > 0 { |
83 | - return protocol.NewErrWithMessage("30001") | 83 | + return protocol.NewErrWithMessage("10002") |
84 | } | 84 | } |
85 | if err := models.DeleteRoleByID(param.RoleID); err != nil { | 85 | if err := models.DeleteRoleByID(param.RoleID); err != nil { |
86 | e := fmt.Errorf("DeleteRole err:%s", err) | 86 | e := fmt.Errorf("DeleteRole err:%s", err) |
@@ -168,7 +168,7 @@ func RoleGroupDelete(param protocol.RequestRoleDelete) error { | @@ -168,7 +168,7 @@ func RoleGroupDelete(param protocol.RequestRoleDelete) error { | ||
168 | return protocol.NewErrWithMessage("1") | 168 | return protocol.NewErrWithMessage("1") |
169 | } | 169 | } |
170 | if cnt > 0 { | 170 | if cnt > 0 { |
171 | - return protocol.NewErrWithMessage("30001") | 171 | + return protocol.NewErrWithMessage("10001") |
172 | } | 172 | } |
173 | err = models.DeleteRoleByID(param.RoleID) | 173 | err = models.DeleteRoleByID(param.RoleID) |
174 | if err != nil { | 174 | if err != nil { |
-
请 注册 或 登录 后发表评论