作者 tangxvhui

提交

... ... @@ -2,6 +2,9 @@ package platform
import (
"errors"
"fmt"
"oppmg/common/log"
"oppmg/models"
)
// ModuleDeparmentData 主管理平台发送过来的数据
... ... @@ -15,6 +18,7 @@ type ModuleDeparmentData struct {
var _ PlatformAction = ModuleDeparmentData{}
//DoAction PlatformAction 的接口实现
func (m ModuleDeparmentData) DoAction(code string) error {
switch code {
case "edit":
... ... @@ -30,15 +34,49 @@ func (m ModuleDeparmentData) DoAction(code string) error {
//同步 部门数据
func UpdateDepartmentData(data ModuleDeparmentData) error {
return nil
}
//AddDepartmentData ...
//TODO :部门管理员数据填充
func AddDepartmentData(data ModuleDeparmentData) error {
// var (
// companyinfo *models.Company
// err error
// )
// models.GetCompanyByUCenter(data.CompanyId)
var (
companyinfo *models.Company
err error
parentDepartment *models.Department
)
companyinfo, err = models.GetCompanyByUCenter(data.CompanyId)
if err != nil {
e := fmt.Errorf("获取公司数据失败,err:%s", err)
log.Error(e.Error())
return errors.New("获取公司数据失败")
}
departmentData := &models.Department{
Id: data.Id,
CompanyId: companyinfo.Id,
Name: data.Name,
ParentId: data.ParentId,
Manages: "[]",
Relation: fmt.Sprintf("%d", data.Id),
}
if data.ParentId > 0 {
parentDepartment, err = models.GetDepartmentById(data.ParentId)
if err != nil {
e := fmt.Errorf("获取父级部门数据失败,err:%s", err)
log.Error(e.Error())
return errors.New("获取父级部门数据失败")
}
departmentData.Relation = fmt.Sprintf("%s/%d", parentDepartment.Relation, data.Id)
}
_, err = models.AddDepartment(departmentData)
if err != nil {
e := fmt.Errorf("存储部门数据失败,err:%s", err)
log.Error(e.Error())
return errors.New("存储部门数据失败")
}
return nil
}
... ...
... ... @@ -14,18 +14,23 @@ type ModuleEmployee struct {
var _ PlatformAction = ModuleEmployee{}
//DoAction PlatformAction 的接口实现
func (m ModuleEmployee) DoAction(code string) error {
return nil
}
// UpdateEmployeeData ...
func UpdateEmployeeData(data ModuleEmployee) error {
return nil
}
// AddEmployeeData ...
func AddEmployeeData(data ModuleEmployee) error {
return nil
}
// DeleteEmployeeData ...
func DeleteEmployeeData(data ModuleEmployee) error {
return nil
}
... ...
... ... @@ -22,6 +22,7 @@ type ModulePositionData struct {
var _ PlatformAction = ModulePositionData{}
//DoAction PlatformAction 的接口实现
func (m ModulePositionData) DoAction(code string) error {
return nil
}
... ...