作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/oppmg into dev

... ... @@ -63,11 +63,8 @@ func (c *CompanyController) DepartmentAdd() {
msg = protocol.BadRequestParam("10043")
return
}
if param.ParentID <= 0 {
msg = protocol.BadRequestParam("10042")
return
}
if param.ParentID == 0 {
//部门必定有上级部门 ,至少是公司一级
msg = protocol.BadRequestParam("10042")
return
... ... @@ -106,6 +103,11 @@ func (c *CompanyController) DepartmentUpdate() {
msg = protocol.BadRequestParam("10043")
return
}
if param.ParentID <= 0 {
//部门必定有上级部门 ,至少是公司一级
msg = protocol.BadRequestParam("10042")
return
}
param.CompanyID = c.GetCompanyId()
if param.ID <= 0 {
log.Error(" param.ID <= 0 ")
... ... @@ -399,7 +401,7 @@ func (c *CompanyController) UserList() {
msg = protocol.BadRequestParam("1")
return
}
param.NickName = strings.TrimSpace(param.NickName)
param.Companyid = c.GetCompanyId()
result, err := servecompany.UserList(param)
msg = protocol.NewPageDataResponse(result, err)
... ... @@ -640,6 +642,10 @@ func (c *CompanyController) CurrentCompanyEdit() {
msg = protocol.BadRequestParam("1")
return
}
if len(param.Logo) == 0 {
msg = protocol.NewReturnResponse(nil, nil)
return
}
companyid := c.GetCompanyId()
err := servecompany.CompanyInfoEdit(companyid, param.Logo)
msg = protocol.NewReturnResponse(nil, err)
... ...
... ... @@ -153,6 +153,7 @@ type TemplateOperateCategoryRequest struct {
Icon string `json:"icon"`
}
type TemplateOperateCategoryResponse struct {
Id int `json:"id"`
}
/*TemplateGet */
... ...
... ... @@ -43,7 +43,7 @@ var errmessge ErrorMap = map[string]string{
// "10040": "注册用户失败",
//部门相关
"10041": "无效的主管设置",
"10042": "无效的上级部门",
"10042": "上级部门不能选择当前部门及其子部门",
"10043": "部门名称限制不超过20个字符",
"10044": "部门名称必填",
"10045": "同一级部门名称不允许重复",
... ...
... ... @@ -121,16 +121,6 @@ func init() {
beego.AddNamespace(nsV1)
beego.AddNamespace(nsAuth)
beego.AddNamespace(nsUcenter)
// nsTest := beego.NewNamespace("/test",
// beego.NSCond(func(ctx *context.Context) bool {
// if beego.BConfig.RunMode != "prod" {
// return true
// }
// return false
// }),
// beego.NSRouter("/te", &controllers.RbacController{}, "get:GetRoleMenuAll"),
// )
// beego.AddNamespace(nsTest)
beego.SetStaticPath("/log", beego.AppConfig.String("log_filename"))
beego.SetStaticPath("/file/opp", beego.AppConfig.String("file_save_path"))
beego.SetStaticPath("/static", "./static")
... ...
... ... @@ -442,6 +442,7 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe
log.Error(err.Error())
return
}
rsp.Id = chanceType.Id
return
}
if len([]rune(request.Code)) > 6 {
... ... @@ -463,6 +464,7 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe
if _, err = models.AddChanceType(chanceType); err != nil {
log.Error(err.Error())
}
rsp.Id = chanceType.Id
return
}
... ...
... ... @@ -171,11 +171,7 @@ func DepartmentEdit(param protocol.RequestDepartmentEdit) error {
log.Error(e.Error())
return protocol.NewErrWithMessage("1", e)
}
r := newparent.Relation
rs := strings.Split(r, "/")
if len(rs) >= 10 { //层级不能超过10级
return protocol.NewErrWithMessage("10046")
}
}
//更新部门关系数据
err = departmentRelationUpdate(departUpdate, newparent)
... ... @@ -234,8 +230,14 @@ func departmentRelationUpdate(departUpdate *models.Department, newparent *models
log.Error(e.Error())
return protocol.NewErrWithMessage("10042")
}
//重建关系树
//确认层级深度
s := strings.TrimPrefix(departSubset[i].Relation, oldRelation)
n := strings.Split(s, "/")
if len(n) >= 0 {
o.Rollback()
return protocol.NewErrWithMessage("10046")
}
//重建关系树
departSubset[i].Relation = strings.TrimSpace(fmt.Sprintf("%s%s", newRelation, s))
err = utils.ExecuteSQLWithOrmer(o, dataSql2, departSubset[i].Relation, departSubset[i].Id)
if err != nil {
... ...
... ... @@ -162,9 +162,6 @@ func PositionEdit(param protocol.RequestPositionEdit) (*protocol.ResponsePositio
//positionRelationUpdate 处理部门上级发生变化的情况
func positionRelationUpdate(positionUpdate *models.Position, newparent *models.Position) error {
if newparent == nil {
return nil
}
const (
//获取某个部门的下级部门 锁数据 select ... for update
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
err error
oldRelation string = positionUpdate.Relation
relationLike string = oldRelation + "%"
newRelation string = fmt.Sprintf("%s/%d", newparent.Relation, positionUpdate.Id)
newRelation string
)
if newparent == nil {
//修改节点为顶层节点的情况
newparent = &models.Position{}
newRelation = fmt.Sprintf("%d", positionUpdate.Id)
} else {
newRelation = fmt.Sprintf("%s/%d", newparent.Relation, positionUpdate.Id)
}
o := orm.NewOrm()
o.Begin()
//修改部门的parent_id
... ... @@ -209,6 +213,11 @@ func positionRelationUpdate(positionUpdate *models.Position, newparent *models.P
}
//重建关系树
s := strings.TrimPrefix(positionSubset[i].Relation, oldRelation)
rs := strings.Split(s, "/")
if len(rs) >= 10 { //层级不能超过10级
o.Rollback()
return protocol.NewErrWithMessage("10012")
}
positionSubset[i].Relation = strings.TrimSpace(fmt.Sprintf("%s%s", newRelation, s))
err = utils.ExecuteSQLWithOrmer(o, dataSql2, positionSubset[i].Relation, positionSubset[i].Id)
if err != nil {
... ...
... ... @@ -165,7 +165,7 @@ func existCompanyUser(companyid int64, phone string) error {
ok := models.ExistUserCompany(userdata.Id, companyid)
if ok {
protocol.NewErrWithMessage("10039")
return protocol.NewErrWithMessage("10039")
}
return nil
}
... ...
... ... @@ -80,7 +80,7 @@ func RoleDelete(param protocol.RequestRoleDelete) error {
return protocol.NewErrWithMessage("1")
}
if cnt > 0 {
return protocol.NewErrWithMessage("30001")
return protocol.NewErrWithMessage("10002")
}
if err := models.DeleteRoleByID(param.RoleID); err != nil {
e := fmt.Errorf("DeleteRole err:%s", err)
... ... @@ -168,7 +168,7 @@ func RoleGroupDelete(param protocol.RequestRoleDelete) error {
return protocol.NewErrWithMessage("1")
}
if cnt > 0 {
return protocol.NewErrWithMessage("30001")
return protocol.NewErrWithMessage("10001")
}
err = models.DeleteRoleByID(param.RoleID)
if err != nil {
... ...