feat(dbfs): set default share shortcut for new users
This commit is contained in:
@@ -246,4 +246,5 @@ var DefaultSettings = map[string]string{
|
||||
"qq_login": `0`,
|
||||
"qq_login_config": `{"direct_sign_in":false}`,
|
||||
"license": "",
|
||||
"default_symbolics": "[]",
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ var (
|
||||
type (
|
||||
ShareClient interface {
|
||||
TxOperator
|
||||
// GetByIDs returns the shares with given ids.
|
||||
GetByIDs(ctx context.Context, ids []int) ([]*ent.Share, error)
|
||||
// GetByID returns the share with given id.
|
||||
GetByID(ctx context.Context, id int) (*ent.Share, error)
|
||||
// GetByIDUser returns the share with given id and user id.
|
||||
@@ -67,6 +69,7 @@ type (
|
||||
UserID int
|
||||
FileID int
|
||||
PublicOnly bool
|
||||
ShareIDs []int
|
||||
}
|
||||
ListShareResult struct {
|
||||
*PaginationResults
|
||||
@@ -168,6 +171,15 @@ func (c *shareClient) GetByIDUser(ctx context.Context, id, uid int) (*ent.Share,
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func (c *shareClient) GetByIDs(ctx context.Context, ids []int) ([]*ent.Share, error) {
|
||||
s, err := withShareEagerLoading(ctx, c.client.Share.Query().Where(share.IDIn(ids...))).All(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to query shares %v: %w", ids, err)
|
||||
}
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func (c *shareClient) DeleteBatch(ctx context.Context, shareIds []int) error {
|
||||
_, err := c.client.Share.Delete().Where(share.IDIn(shareIds...)).Exec(ctx)
|
||||
return err
|
||||
@@ -332,6 +344,10 @@ func (c *shareClient) listQuery(args *ListShareArgs) *ent.ShareQuery {
|
||||
query.Where(share.HasFileWith(file.ID(args.FileID)))
|
||||
}
|
||||
|
||||
if len(args.ShareIDs) > 0 {
|
||||
query.Where(share.IDIn(args.ShareIDs...))
|
||||
}
|
||||
|
||||
return query
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user