更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -10,18 +10,6 @@ import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
// 项目文档(CRM 项目 ↔ OA 文档库)绑定业务逻辑。
|
||||
//
|
||||
// 约定:每个项目在文档库「共享文档 / 项目文档」下拥有一个与项目同名的文件夹,
|
||||
// 项目管理侧负责调用与文件上传,文件统一写入文档库(yz_backend_oa_doc),
|
||||
// 文档库侧负责浏览、图谱与共享。项目表用 doc_category_id 记住自己文件夹的分类ID,
|
||||
// 项目改名时同步重命名文件夹;存量项目在首次访问项目文档时自动补建。
|
||||
|
||||
// EnsureCrmProjectDocCategory 确保项目在文档库「共享文档 / 项目文档」下拥有同名文件夹,返回文件夹分类ID。
|
||||
//
|
||||
// 兼容存量项目:项目上的分类ID为空(0)或指向已删除分类时自动补建,并回写项目表;
|
||||
// 若「项目文档」下已有同名且未被其它项目占用的文件夹则复用,避免重复建目录。
|
||||
// 失败时返回 error(由调用方决定是否阻断,建议静默忽略,不影响项目主流程)。
|
||||
func EnsureCrmProjectDocCategory(tid int, projectID uint64, projectName string, currentCategoryID uint64) (uint64, error) {
|
||||
if models.Orm == nil || tid <= 0 {
|
||||
return 0, nil
|
||||
@@ -33,7 +21,6 @@ func EnsureCrmProjectDocCategory(tid int, projectID uint64, projectName string,
|
||||
|
||||
models.EnsureOaDocDefaultCategories(tid)
|
||||
|
||||
// 1. 已绑定且分类仍有效:直接返回
|
||||
if currentCategoryID > 0 {
|
||||
n, err := models.Orm.QueryTable(new(models.OaDocCategory)).
|
||||
Filter("tid", tid).
|
||||
@@ -44,13 +31,11 @@ func EnsureCrmProjectDocCategory(tid int, projectID uint64, projectName string,
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 定位「项目文档」内置分类(首次访问时已由 EnsureOaDocDefaultCategories 补建)
|
||||
rootID, err := crmProjectDocRootCategory(tid)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// 3. 复用「项目文档」下同名且未被其它项目占用的文件夹(同名项目共存时各用各的)
|
||||
var sameName []models.OaDocCategory
|
||||
if _, err := models.Orm.QueryTable(new(models.OaDocCategory)).
|
||||
Filter("tid", tid).
|
||||
@@ -72,7 +57,6 @@ func EnsureCrmProjectDocCategory(tid int, projectID uint64, projectName string,
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 新建项目同名文件夹
|
||||
item := &models.OaDocCategory{
|
||||
Tid: tid,
|
||||
UserID: 0,
|
||||
@@ -92,7 +76,6 @@ func EnsureCrmProjectDocCategory(tid int, projectID uint64, projectName string,
|
||||
return categoryID, crmProjectDocBindCategory(tid, projectID, categoryID)
|
||||
}
|
||||
|
||||
// RenameCrmProjectDocCategory 项目改名时同步重命名文档库中的项目文件夹(失败由调用方处理)。
|
||||
func RenameCrmProjectDocCategory(tid int, categoryID uint64, newName string) error {
|
||||
newName = strings.TrimSpace(newName)
|
||||
if models.Orm == nil || tid <= 0 || categoryID == 0 || newName == "" {
|
||||
@@ -114,7 +97,6 @@ func RenameCrmProjectDocCategory(tid int, categoryID uint64, newName string) err
|
||||
return err
|
||||
}
|
||||
|
||||
// CrmProjectDocCategoryNameMap 返回租户内未删除分类的 ID -> 名称映射(项目文档列表展示文件夹名用)。
|
||||
func CrmProjectDocCategoryNameMap(tid int) map[uint64]string {
|
||||
result := make(map[uint64]string)
|
||||
if models.Orm == nil || tid <= 0 {
|
||||
@@ -131,8 +113,6 @@ func CrmProjectDocCategoryNameMap(tid int) map[uint64]string {
|
||||
return result
|
||||
}
|
||||
|
||||
// CrmProjectDocCategoryInScope 判断分类是否位于项目文件夹内(含项目文件夹自身)。
|
||||
// 用于约束项目侧的文件夹创建、文件上传与删除只能在项目自己的目录下操作。
|
||||
func CrmProjectDocCategoryInScope(a OaDocActor, rootID, categoryID uint64) bool {
|
||||
if rootID == 0 || categoryID == 0 {
|
||||
return false
|
||||
@@ -152,7 +132,6 @@ func CrmProjectDocCategoryInScope(a OaDocActor, rootID, categoryID uint64) bool
|
||||
return false
|
||||
}
|
||||
|
||||
// ProjectDocFolder 项目文档文件夹树节点(含该文件夹直接挂载的文档数量)。
|
||||
type ProjectDocFolder struct {
|
||||
ID uint64 `json:"id"`
|
||||
ParentID uint64 `json:"parent_id"`
|
||||
@@ -161,8 +140,6 @@ type ProjectDocFolder struct {
|
||||
Children []*ProjectDocFolder `json:"children"`
|
||||
}
|
||||
|
||||
// CrmProjectDocFolderTree 构建项目文件夹树(根为项目文件夹,含全部子孙文件夹)。
|
||||
// 「项目文档」下的同名文件夹即项目根,用户在项目内新建的文件夹为其子分类。
|
||||
func CrmProjectDocFolderTree(a OaDocActor, rootID uint64) ([]*ProjectDocFolder, error) {
|
||||
empty := []*ProjectDocFolder{}
|
||||
if rootID == 0 {
|
||||
@@ -175,7 +152,6 @@ func CrmProjectDocFolderTree(a OaDocActor, rootID uint64) ([]*ProjectDocFolder,
|
||||
}
|
||||
nodes := make(map[uint64]*ProjectDocFolder, len(list))
|
||||
for i := range list {
|
||||
// 项目文件夹属于共享空间(scope=shared、user_id=0)
|
||||
if list[i].Scope != models.DocScopeShared || list[i].UserID != 0 {
|
||||
continue
|
||||
}
|
||||
@@ -190,7 +166,6 @@ func CrmProjectDocFolderTree(a OaDocActor, rootID uint64) ([]*ProjectDocFolder,
|
||||
if !ok {
|
||||
return empty, nil
|
||||
}
|
||||
// 按 id 顺序挂接父子关系;只有能与根连通的节点才会出现在项目子树中
|
||||
for i := range list {
|
||||
node, ok := nodes[list[i].ID]
|
||||
if !ok || node.ID == rootID {
|
||||
@@ -200,7 +175,6 @@ func CrmProjectDocFolderTree(a OaDocActor, rootID uint64) ([]*ProjectDocFolder,
|
||||
parent.Children = append(parent.Children, node)
|
||||
}
|
||||
}
|
||||
// 附带各文件夹直接挂载的文档数量(仅展示用,不汇总子孙)
|
||||
if counts, err := OaDocCountByCategory(a, models.DocScopeShared, -1); err == nil {
|
||||
for id, cnt := range counts {
|
||||
if n, ok := nodes[id]; ok {
|
||||
@@ -211,7 +185,6 @@ func CrmProjectDocFolderTree(a OaDocActor, rootID uint64) ([]*ProjectDocFolder,
|
||||
return []*ProjectDocFolder{root}, nil
|
||||
}
|
||||
|
||||
// crmProjectDocRootCategory 查找租户「项目文档」内置分类;缺失时兜底重建(正常由文档库初始化保证存在)。
|
||||
func crmProjectDocRootCategory(tid int) (uint64, error) {
|
||||
var root models.OaDocCategory
|
||||
err := models.Orm.QueryTable(new(models.OaDocCategory)).
|
||||
@@ -240,7 +213,6 @@ func crmProjectDocRootCategory(tid int) (uint64, error) {
|
||||
return uint64(id), nil
|
||||
}
|
||||
|
||||
// crmProjectDocCategoryBound 判断分类是否已被同租户的其它项目占用(excludeProjectID 为当前项目)。
|
||||
func crmProjectDocCategoryBound(tid int, categoryID, excludeProjectID uint64) (bool, error) {
|
||||
qs := models.Orm.QueryTable(new(models.TenantCrmProject)).
|
||||
Filter("tenant_id", strconv.Itoa(tid)).
|
||||
@@ -256,7 +228,6 @@ func crmProjectDocCategoryBound(tid int, categoryID, excludeProjectID uint64) (b
|
||||
return n > 0, nil
|
||||
}
|
||||
|
||||
// crmProjectDocBindCategory 回写项目与文档分类的绑定关系(projectID=0 时跳过)。
|
||||
func crmProjectDocBindCategory(tid int, projectID, categoryID uint64) error {
|
||||
if projectID == 0 {
|
||||
return nil
|
||||
|
||||
Reference in new issue
Block a user