优化backend端相关功能
This commit is contained in:
@@ -73,7 +73,6 @@ type organizationDTO struct {
|
||||
Sort uint `json:"sort"`
|
||||
Status int8 `json:"status"`
|
||||
Remark string `json:"remark"`
|
||||
EmployeeCount int64 `json:"employee_count"`
|
||||
CreateTime string `json:"create_time"`
|
||||
UpdateTime string `json:"update_time"`
|
||||
}
|
||||
@@ -958,6 +957,9 @@ func (c *BackendOrganizationController) CreateEmployee() {
|
||||
return
|
||||
}
|
||||
|
||||
// 同步到通讯录(员工为基础数据,已建档时档案字段优先)
|
||||
SyncContactOnEmployeeCreate(tid, uint64(id), &row)
|
||||
|
||||
c.jsonOK(map[string]interface{}{"id": id, "account": account})
|
||||
}
|
||||
|
||||
@@ -1063,10 +1065,19 @@ func (c *BackendOrganizationController) EditEmployee() {
|
||||
return
|
||||
}
|
||||
|
||||
// 同步到通讯录(字段优先级:人事档案 > 员工)
|
||||
SyncContactOnEmployeeRefresh(tid, uint64(id))
|
||||
|
||||
c.jsonOK(nil)
|
||||
}
|
||||
|
||||
// DeleteEmployee 删除员工(软删除)。
|
||||
// DeleteEmployee 员工离职/禁用:员工不做删除,只改账号状态。
|
||||
//
|
||||
// 说明:员工属于企业数据,人事档案(yz_backend_employee_file)与通讯录
|
||||
//(yz_backend_erp_contact)都以 employee_id 关联员工。一旦把员工软删除(写 delete_time),
|
||||
// 档案页与通讯录就查不到对应的人,等于连带删掉了企业数据。
|
||||
// 因此这里只把账号状态置为"离职"(2),不写 delete_time,也不触碰档案与通讯录记录。
|
||||
// 启用/禁用请走 editEmployee 改 account_status(1 启用 / 0 禁用 / 2 离职)。
|
||||
// DELETE /backend/{erp|oa}/deleteEmployee/:id
|
||||
func (c *BackendOrganizationController) DeleteEmployee() {
|
||||
tid, ok := c.tenantID()
|
||||
@@ -1079,14 +1090,15 @@ func (c *BackendOrganizationController) DeleteEmployee() {
|
||||
return
|
||||
}
|
||||
|
||||
num, err := c.employeeQuery(tid).Filter("id", id).
|
||||
Update(orm.Params{"delete_time": c.nowString(), "account_status": int8(2)})
|
||||
if err != nil {
|
||||
c.jsonError(500, "删除员工失败: "+err.Error())
|
||||
if !c.employeeQuery(tid).Filter("id", id).Exist() {
|
||||
c.jsonError(404, "员工不存在")
|
||||
return
|
||||
}
|
||||
if num == 0 {
|
||||
c.jsonError(404, "员工不存在")
|
||||
|
||||
// 员工不允许删除,仅置为离职状态;档案与通讯录原样保留
|
||||
if _, err := c.employeeQuery(tid).Filter("id", id).
|
||||
Update(orm.Params{"account_status": int8(2)}); err != nil {
|
||||
c.jsonError(500, "离职操作失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user