feat: 按创建人隔离采集采购任务 (#127)

This commit is contained in:
chengma
2026-08-10 23:10:28 +08:00
parent 74f99f37d0
commit a9f22b9b0e
24 changed files with 655 additions and 74 deletions
+14
View File
@@ -21,6 +21,9 @@ import (
// 补完实现后要把对应的返回删掉,不要留着假装能用。
var ErrNotImplemented = errors.New("功能尚未实现")
// ErrTaskNotVisible 同时表示任务不存在和不在当前账号范围,避免泄露他人任务。
var ErrTaskNotVisible = errors.New("任务不存在或不在当前账号可见范围")
// ---------- 蝦皮 Excel 导入 ----------
//
// ImportResult / ImportShopeeExcel / ParseSpec 的实现见 shopee_import.go,
@@ -125,6 +128,17 @@ func visibleClientUserID(actor *model.User) (string, error) {
return visibleUserID, nil
}
// taskActorScope 校验可创建/管理任务的网页登录账号,并返回客户端/任务可见范围。
func taskActorScope(actor *model.User) (string, error) {
if actor == nil {
return "", ErrUnauthenticated
}
if actor.Status != model.UserActive {
return "", fmt.Errorf("当前账号不是正常状态,不能操作任务")
}
return visibleClientUserID(actor)
}
func listClientViews(db *sql.DB, keyword, visibleUserID string, threshold time.Duration) ([]ClientView, error) {
clients, err := repository.ListClientsForUser(db, keyword, visibleUserID)
if err != nil {