feat: implement core backend for team owner management with SQLite, auto-add APIs, and a frontend owner list component.
This commit is contained in:
@@ -189,7 +189,8 @@ func (d *DB) GetTeamOwners(status string, limit, offset int) ([]TeamOwner, int,
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
query += " ORDER BY created_at DESC LIMIT ? OFFSET ?"
|
||||
// 排序:已使用(used, pooled)排前面,其次按创建时间降序
|
||||
query += " ORDER BY CASE WHEN status IN ('used', 'pooled') THEN 0 ELSE 1 END, created_at DESC LIMIT ? OFFSET ?"
|
||||
args = append(args, limit, offset)
|
||||
|
||||
rows, err := d.db.Query(query, args...)
|
||||
@@ -277,6 +278,15 @@ func (d *DB) ClearTeamOwners() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// ClearUsedOwners 清理已使用的母号(status = 'used' 或 'pooled')
|
||||
func (d *DB) ClearUsedOwners() (int64, error) {
|
||||
result, err := d.db.Exec("DELETE FROM team_owners WHERE status IN ('used', 'pooled')")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return result.RowsAffected()
|
||||
}
|
||||
|
||||
// GetOwnersWithoutAccountID 获取缺少 account_id 的 owners
|
||||
func (d *DB) GetOwnersWithoutAccountID() ([]TeamOwner, error) {
|
||||
rows, err := d.db.Query(`
|
||||
|
||||
Reference in New Issue
Block a user