更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -13,14 +13,6 @@ import (
|
||||
"server/models"
|
||||
)
|
||||
|
||||
// 本文件包含组织架构模块的 DTO 组装、树结构与层级校验,以及请求参数解析工具。
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// DTO 组装
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// organizationDTOList 批量组装组织 DTO。一次性把父组织名、负责人名、员工数查出来,
|
||||
// 避免逐行查询导致的 N+1 问题。
|
||||
func (c *BackendOrganizationController) organizationDTOList(tid uint64, rows []models.BackendOrganization) []organizationDTO {
|
||||
list := make([]organizationDTO, 0, len(rows))
|
||||
if len(rows) == 0 {
|
||||
@@ -147,7 +139,6 @@ func (c *BackendOrganizationController) positionDTO(tid uint64, row models.Backe
|
||||
Remark: derefString(row.Remark),
|
||||
CreateTime: formatDateTime(&row.CreateTime),
|
||||
}
|
||||
// 职级名称:职位挂了职级才显示,未设置时留空由前端显示「-」。
|
||||
if row.RankID > 0 {
|
||||
if rank, ok := c.jobRankMap(tid)[row.RankID]; ok {
|
||||
dto.RankName = rank.RankName
|
||||
@@ -157,7 +148,6 @@ func (c *BackendOrganizationController) positionDTO(tid uint64, row models.Backe
|
||||
return dto
|
||||
}
|
||||
|
||||
// jobRankMap 取租户内的职级映射,单次请求内只查一次。
|
||||
func (c *BackendOrganizationController) jobRankMap(tid uint64) map[uint64]models.BackendJobRank {
|
||||
if c.jobRanks == nil || c.jobRanksTid != tid {
|
||||
c.jobRanks = JobRankMap(tid)
|
||||
@@ -166,10 +156,6 @@ func (c *BackendOrganizationController) jobRankMap(tid uint64) map[uint64]models
|
||||
return c.jobRanks
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 组织关系查询
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
func (c *BackendOrganizationController) orgNameMap(tid uint64) map[uint64]string {
|
||||
result := map[uint64]string{}
|
||||
var rows []models.BackendOrganization
|
||||
@@ -201,7 +187,6 @@ func (c *BackendOrganizationController) orgExists(tid, id uint64) bool {
|
||||
return c.orgQuery(tid).Filter("id", id).Exist()
|
||||
}
|
||||
|
||||
// parentMap 返回 组织ID -> 上级组织ID 的映射,用于层级与环路判断。
|
||||
func (c *BackendOrganizationController) parentMap(tid uint64) map[uint64]uint64 {
|
||||
result := map[uint64]uint64{}
|
||||
var rows []models.BackendOrganization
|
||||
@@ -214,7 +199,6 @@ func (c *BackendOrganizationController) parentMap(tid uint64) map[uint64]uint64
|
||||
return result
|
||||
}
|
||||
|
||||
// orgDepth 计算组织所在层级,顶级为 1。
|
||||
func (c *BackendOrganizationController) orgDepth(tid, id uint64) (int, error) {
|
||||
parents := c.parentMap(tid)
|
||||
depth := 0
|
||||
@@ -233,7 +217,6 @@ func (c *BackendOrganizationController) orgDepth(tid, id uint64) (int, error) {
|
||||
return depth, nil
|
||||
}
|
||||
|
||||
// subtreeHeight 计算以 id 为根的子树高度(只有自身时为 1)。
|
||||
func (c *BackendOrganizationController) subtreeHeight(tid, id uint64) int {
|
||||
childrenOf := map[uint64][]uint64{}
|
||||
var rows []models.BackendOrganization
|
||||
@@ -259,7 +242,6 @@ func subtreeHeightFrom(childrenOf map[uint64][]uint64, id uint64, depth int) int
|
||||
return height
|
||||
}
|
||||
|
||||
// collectOrgIDs 返回 rootID 及其所有下级组织的ID。
|
||||
func (c *BackendOrganizationController) collectOrgIDs(tid, rootID uint64) []uint64 {
|
||||
childrenOf := map[uint64][]uint64{}
|
||||
var rows []models.BackendOrganization
|
||||
@@ -288,7 +270,6 @@ func (c *BackendOrganizationController) collectOrgIDs(tid, rootID uint64) []uint
|
||||
return result
|
||||
}
|
||||
|
||||
// rootCompanyID 沿上级链向上找到所属的顶层公司ID。
|
||||
func (c *BackendOrganizationController) rootCompanyID(tid uint64, org models.BackendOrganization) uint64 {
|
||||
if org.IsCompany == 1 {
|
||||
return org.ID
|
||||
@@ -312,8 +293,6 @@ func (c *BackendOrganizationController) rootCompanyID(tid uint64, org models.Bac
|
||||
return 0
|
||||
}
|
||||
|
||||
// validateParentChange 校验把 orgID 挂到 newParentID 下是否合法:
|
||||
// 不能挂到自己或自己的后代(形成环路),且移动后总层级不超过设置上限。
|
||||
func (c *BackendOrganizationController) validateParentChange(tid, orgID, newParentID uint64, settings orgSettings) error {
|
||||
if newParentID == 0 {
|
||||
return nil
|
||||
@@ -348,7 +327,6 @@ func (c *BackendOrganizationController) validateParentChange(tid, orgID, newPare
|
||||
return nil
|
||||
}
|
||||
|
||||
// validateEmployeeOrg 校验员工的隶属单位与部门必须是当前租户下已存在的组织。
|
||||
func (c *BackendOrganizationController) validateEmployeeOrg(tid uint64, affiliateUnit, department string) error {
|
||||
for label, raw := range map[string]string{"隶属单位": affiliateUnit, "部门": department} {
|
||||
raw = strings.TrimSpace(raw)
|
||||
@@ -397,7 +375,6 @@ func buildOrganizationTree(list []organizationDTO) []map[string]interface{} {
|
||||
return tree
|
||||
}
|
||||
|
||||
// treeDepth 计算树的最大深度。
|
||||
func treeDepth(childrenOf map[uint64][]uint64, rootID uint64, depth int) int {
|
||||
if depth > 64 {
|
||||
return depth
|
||||
@@ -454,7 +431,6 @@ func maxInt(a, b int) int {
|
||||
return b
|
||||
}
|
||||
|
||||
// generateCode 生成形如 ORG20260827193012 的编码,长度不足时补时间戳末尾数字。
|
||||
func (c *BackendOrganizationController) generateCode(prefix string, length int) string {
|
||||
prefix = strings.TrimSpace(prefix)
|
||||
stamp := time.Now().Format("20060102150405")
|
||||
@@ -466,7 +442,6 @@ func (c *BackendOrganizationController) generateCode(prefix string, length int)
|
||||
return code
|
||||
}
|
||||
|
||||
// hashEmployeePassword 适配 password varchar(64),使用 sha256 hex;空密码返回空串。
|
||||
func hashEmployeePassword(plain string) string {
|
||||
plain = strings.TrimSpace(plain)
|
||||
if plain == "" {
|
||||
|
||||
Reference in new issue
Block a user