Repository navigation
chore(release): 同步社团生命周期与项目导师修复 #239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
eb83ef8
test(project): 覆盖教师导师候选
Palind-Rome 55d4111
fix(club,project): 清理解散社团视图并支持教师导师
Palind-Rome c96d2dc
chore(api): 从 openapi.yaml 自动生成 API 代码
Palind-Rome 7b2008f
Merge pull request #238 from Palind-Rome/fix/237-club-lifecycle-proje…
Palind-Rome File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| using System.Net.Http.Headers; | ||
| using System.Text.Json; | ||
| using ClubHub.Api.Data; | ||
| using ClubHub.Api.Data.Entities; | ||
| using ClubHub.Api.Services; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
|
|
||
| namespace ClubHub.Api.Tests; | ||
|
|
||
| public sealed class ClubVisibilityTests : IClassFixture<ClubHubWebApplicationFactory> | ||
| { | ||
| private readonly ClubHubWebApplicationFactory _factory; | ||
| private static int _sequence; | ||
|
|
||
| public ClubVisibilityTests(ClubHubWebApplicationFactory factory) => _factory = factory; | ||
|
|
||
| [Fact] | ||
| public async Task PublicClubList_ExcludesUnapprovedOrInactiveClubs() | ||
| { | ||
| var baseId = 9_300_000 + Interlocked.Increment(ref _sequence) * 10; | ||
| await using var scope = _factory.Services.CreateAsyncScope(); | ||
| var db = scope.ServiceProvider.GetRequiredService<ClubHubDbContext>(); | ||
| db.Clubs.AddRange( | ||
| new Club | ||
| { | ||
| ClubId = baseId, | ||
| ClubName = "可见运营社团", | ||
| AuditStatus = "approved", | ||
| ClubStatus = "active", | ||
| CreatedAt = DateTime.UtcNow | ||
| }, | ||
| new Club | ||
| { | ||
| ClubId = baseId + 1, | ||
| ClubName = "已解散社团", | ||
| AuditStatus = "approved", | ||
| ClubStatus = "inactive", | ||
| CreatedAt = DateTime.UtcNow | ||
| }, | ||
| new Club | ||
| { | ||
| ClubId = baseId + 2, | ||
| ClubName = "待审核社团", | ||
| AuditStatus = "pending", | ||
| ClubStatus = "pending", | ||
| CreatedAt = DateTime.UtcNow | ||
| }); | ||
| await db.SaveChangesAsync(); | ||
|
|
||
| using var client = _factory.CreateClient(); | ||
| using var response = await client.GetAsync("/api/v1/clubs"); | ||
|
|
||
| response.EnsureSuccessStatusCode(); | ||
| using var body = JsonDocument.Parse(await response.Content.ReadAsStringAsync()); | ||
| var names = body.RootElement.EnumerateArray() | ||
| .Select(club => club.GetProperty("name").GetString()) | ||
| .ToArray(); | ||
| Assert.Contains("可见运营社团", names); | ||
| Assert.DoesNotContain("已解散社团", names); | ||
| Assert.DoesNotContain("待审核社团", names); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task MemberClubList_ExcludesDissolvedClubFromOperationalWorkspaces() | ||
| { | ||
| var baseId = 9_301_000 + Interlocked.Increment(ref _sequence) * 10; | ||
| await using var scope = _factory.Services.CreateAsyncScope(); | ||
| var db = scope.ServiceProvider.GetRequiredService<ClubHubDbContext>(); | ||
| var now = DateTime.UtcNow; | ||
| db.Users.Add(new User | ||
| { | ||
| UserId = baseId, | ||
| Username = $"club-visibility-user-{baseId}", | ||
| PasswordHash = "unused", | ||
| RealName = "社团可见性测试用户", | ||
| AccountStatus = "normal", | ||
| CreatedAt = now | ||
| }); | ||
| db.Clubs.AddRange( | ||
| new Club | ||
| { | ||
| ClubId = baseId + 1, | ||
| ClubName = "成员可见运营社团", | ||
| AuditStatus = "approved", | ||
| ClubStatus = "active", | ||
| CreatedAt = now | ||
| }, | ||
| new Club | ||
| { | ||
| ClubId = baseId + 2, | ||
| ClubName = "成员不可见解散社团", | ||
| AuditStatus = "approved", | ||
| ClubStatus = "inactive", | ||
| CreatedAt = now | ||
| }); | ||
| db.ClubMembers.AddRange( | ||
| new ClubMember | ||
| { | ||
| MemberId = baseId + 3, | ||
| ClubId = baseId + 1, | ||
| UserId = baseId, | ||
| MemberStatus = "active", | ||
| TermStart = now.AddDays(-1), | ||
| TermEnd = now.AddDays(30) | ||
| }, | ||
| new ClubMember | ||
| { | ||
| MemberId = baseId + 4, | ||
| ClubId = baseId + 2, | ||
| UserId = baseId, | ||
| MemberStatus = "active", | ||
| TermStart = now.AddDays(-1), | ||
| TermEnd = now.AddDays(30) | ||
| }); | ||
| await db.SaveChangesAsync(); | ||
|
|
||
| var token = scope.ServiceProvider.GetRequiredService<AuthTokenService>().CreateToken( | ||
| new User { UserId = baseId, Username = $"club-visibility-user-{baseId}" }); | ||
| using var client = _factory.CreateClient(); | ||
| client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); | ||
| using var response = await client.GetAsync("/api/v1/clubs"); | ||
|
|
||
| response.EnsureSuccessStatusCode(); | ||
| using var body = JsonDocument.Parse(await response.Content.ReadAsStringAsync()); | ||
| var names = body.RootElement.EnumerateArray() | ||
| .Select(club => club.GetProperty("name").GetString()) | ||
| .ToArray(); | ||
| Assert.Contains("成员可见运营社团", names); | ||
| Assert.DoesNotContain("成员不可见解散社团", names); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
让
GetCandidateUsersQuery使用统一的教师资格表达式不能将教师分支直接改为当前仅接受 5 位数字的
IsTeacher,否则会排除通过教师角色识别的合法教师。GetCandidateUsersQuery应与AddMember共用同一套、可被 EF Core/Oracle 翻译的教师资格条件,并保留当前有效社团成员条件:同时返回教师资格和当前有效社团成员资格,供前端按 API 字段筛选。仅修复共享教师资格判断和 API 字段,不能替代此处对候选查询条件的同步修改;否则无角色但符合教师资格的账号仍可能无法进入候选列表,角色不匹配的账号也可能出现后续添加失败。
🤖 Prompt for AI Agents