This commit is contained in:
2026-08-28 14:04:46 +08:00
parent 99df6c08ac
commit 9588ddbf31
8 changed files with 42 additions and 1602 deletions
+9 -9
View File
@@ -358,14 +358,14 @@ func (c *BackendErpContactController) Star() {
func (c *BackendErpContactController) SyncAllContacts() {
tid, _ := c.GetInt64("tid")
qs := models.Orm.QueryTable(new(models.BackendErpEmployee)).
qs := models.Orm.QueryTable(new(models.BackendEmployee)).
Filter("delete_time__isnull", true).
Exclude("account_status", 2)
if tid > 0 {
qs = qs.Filter("tid", tid)
}
var employees []models.BackendErpEmployee
var employees []models.BackendEmployee
_, err := qs.All(&employees)
if err != nil {
c.contactJsonError(500, "查询员工失败: "+err.Error())
@@ -400,14 +400,14 @@ func (c *BackendErpContactController) SyncAllContacts() {
func (c *BackendErpContactController) GetContactOrgTree() {
tid, _ := c.GetInt64("tid")
qs := models.Orm.QueryTable(new(models.BackendErpOrganization)).
qs := models.Orm.QueryTable(new(models.BackendOrganization)).
Filter("delete_time__isnull", true).
Exclude("status", 0)
if tid > 0 {
qs = qs.Filter("tid", tid)
}
var orgs []models.BackendErpOrganization
var orgs []models.BackendOrganization
_, err := qs.OrderBy("sort", "id").All(&orgs)
if err != nil {
c.contactJsonError(500, "查询组织架构失败: "+err.Error())
@@ -455,7 +455,7 @@ func (c *BackendErpContactController) GetContactOrgTree() {
// buildContactOrgTree 构建通讯录组织树
func (c *BackendErpContactController) buildContactOrgTree(
orgs []models.BackendErpOrganization,
orgs []models.BackendOrganization,
counts map[uint64]int64,
totalInternal uint64,
) []map[string]interface{} {
@@ -495,8 +495,8 @@ func (c *BackendErpContactController) buildContactOrgTree(
func (c *BackendErpContactController) contactDTO(row models.BackendErpContact) erpContactDTO {
orgName := ""
if row.OrgID != nil && *row.OrgID > 0 {
var org models.BackendErpOrganization
if err := models.Orm.QueryTable(new(models.BackendErpOrganization)).
var org models.BackendOrganization
if err := models.Orm.QueryTable(new(models.BackendOrganization)).
Filter("id", *row.OrgID).
One(&org); err == nil {
orgName = org.OrgName
@@ -533,7 +533,7 @@ func (c *BackendErpContactController) contactDTO(row models.BackendErpContact) e
// --- Sync from Employee ---
// SyncContactOnEmployeeCreate 员工创建后同步到通讯录(由 ERP 控制器调用)
func SyncContactOnEmployeeCreate(tid uint64, employeeID uint64, emp *models.BackendErpEmployee) {
func SyncContactOnEmployeeCreate(tid uint64, employeeID uint64, emp *models.BackendEmployee) {
syncContactFromEmployee(tid, employeeID, emp)
}
@@ -622,7 +622,7 @@ func SyncContactOnEmployeeDelete(employeeID uint64) {
}
// syncContactFromEmployee 内部同步函数
func syncContactFromEmployee(tid uint64, employeeID uint64, emp *models.BackendErpEmployee) string {
func syncContactFromEmployee(tid uint64, employeeID uint64, emp *models.BackendEmployee) string {
var existing models.BackendErpContact
err := models.Orm.QueryTable(new(models.BackendErpContact)).
Filter("employee_id", employeeID).
+24 -22
View File
@@ -2,8 +2,8 @@ package models
import "time"
// BackendErpOrganization 全局组织架构表 yz_backend_organization
type BackendErpOrganization struct {
// BackendOrganization 全局组织架构表 yz_backend_organization
type BackendOrganization struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
Tid uint64 `orm:"column(tid)" json:"tid"`
OrgName string `orm:"column(org_name);size(128)" json:"org_name"`
@@ -20,12 +20,12 @@ type BackendErpOrganization struct {
}
// TableName 自定义表名
func (m *BackendErpOrganization) TableName() string {
return "yz_backend_erp_organization"
func (m *BackendOrganization) TableName() string {
return "yz_backend_organization"
}
// BackendErpEmployee 员工信息表 yz_backend_erp_employee
type BackendErpEmployee struct {
// BackendEmployee 全局员工信息表 yz_backend_employee
type BackendEmployee struct {
ID uint `orm:"column(id);pk;auto" json:"id"`
Tid *int `orm:"column(tid);null" json:"tid"`
Account string `orm:"column(account);size(50)" json:"account"`
@@ -49,25 +49,27 @@ type BackendErpEmployee struct {
}
// TableName 自定义表名
func (m *BackendErpEmployee) TableName() string {
return "yz_backend_erp_employee"
func (m *BackendEmployee) TableName() string {
return "yz_backend_employee"
}
// BackendErpPosition 职位表 yz_backend_erp_position
type BackendErpPosition struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
Tid uint64 `orm:"column(tid)" json:"tid"`
DepartmentID uint64 `orm:"column(department_id)" json:"department_id"`
PositionCode string `orm:"column(position_code);size(50)" json:"position_code"`
PositionName string `orm:"column(position_name);size(100)" json:"position_name"`
PositionType int8 `orm:"column(position_type);default(0)" json:"position_type"`
Status int8 `orm:"column(status);default(1)" json:"status"`
Sort uint `orm:"column(sort);default(0)" json:"sort"`
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
UpdateTime time.Time `orm:"column(update_time);auto_now;type(datetime)" json:"update_time"`
// BackendPosition 全局职位表 yz_backend_position
type BackendPosition struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
Tid uint64 `orm:"column(tid)" json:"tid"`
DepartmentID uint64 `orm:"column(department_id)" json:"department_id"`
PositionCode string `orm:"column(position_code);size(50)" json:"position_code"`
PositionName string `orm:"column(position_name);size(100)" json:"position_name"`
PositionType int8 `orm:"column(position_type);default(0)" json:"position_type"`
Status int8 `orm:"column(status);default(1)" json:"status"`
Sort uint `orm:"column(sort);default(0)" json:"sort"`
Remark *string `orm:"column(remark);size(512);null" json:"remark"`
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
UpdateTime time.Time `orm:"column(update_time);auto_now;type(datetime)" json:"update_time"`
DeleteTime *time.Time `orm:"column(delete_time);type(datetime);null" json:"delete_time"`
}
// TableName 自定义表名
func (m *BackendErpPosition) TableName() string {
return "yz_backend_erp_position"
func (m *BackendPosition) TableName() string {
return "yz_backend_position"
}
+3 -3
View File
@@ -35,9 +35,9 @@ func Init(_ string) {
orm.RegisterModel(
new(SystemTenant),
new(SystemTenantUser),
new(BackendErpOrganization),
new(BackendErpEmployee),
new(BackendErpPosition),
new(BackendOrganization),
new(BackendEmployee),
new(BackendPosition),
new(BackendErpContact),
new(BackendApprovalFlow),
new(BackendApprovalRecord),