Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Commit

Permalink
feat: update announcement module
Browse files Browse the repository at this point in the history
  • Loading branch information
YanceyOfficial committed Feb 1, 2020
1 parent 7b856c5 commit fee7776
Show file tree
Hide file tree
Showing 4 changed files with 290 additions and 8 deletions.
281 changes: 281 additions & 0 deletions schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,311 @@ type AnnouncementModel {
updatedAt: String!
}

type AuthModel {
_id: ID!
authorization: String!
username: String!
email: String!
password: String!
role: Float!
avaterUrl: String!
phoneNumber: String!
isTOTP: Boolean!
createdAt: String!
updatedAt: String!
}

type BatchDeleteModel {
ok: Float
n: Float
deletedCount: Float
ids: [ID!]!
}

type BatchUpdateModel {
ok: Float
n: Float
nModified: Float
}

type BestAlbumModel {
_id: ID!
title: String!
artist: String!
coverUrl: String!
mvUrl: String!
releaseDate: String!
createdAt: String!
updatedAt: String!
}

input CreateAnnouncementInput {
content: String!
}

input CreateBestAlbumInput {
title: String!
artist: String!
coverUrl: String!
mvUrl: String!
releaseDate: String!
}

input CreateLiveTourInput {
title: String!
posterUrl: String!
showTime: String!
}

input CreateOpenSourceInput {
title: String!
description: String!
url: String!
posterUrl: String!
}

input CreatePlayerInput {
title: String!
artist: String!
lrc: String!
coverUrl: String!
musicFileUrl: String!
isPublic: Boolean!
}

input CreateYanceyMusicInput {
title: String!
soundCloudUrl: String!
posterUrl: String!
releaseDate: String!
}

type LiveTourModel {
_id: ID!
title: String!
posterUrl: String!
showTime: String!
createdAt: String!
updatedAt: String!
}

input LoginInput {
email: String!
password: String!
}

type Mutation {
register(input: RegisterInput!): AuthModel!
createAnnouncement(input: CreateAnnouncementInput!): AnnouncementModel!
updateAnnouncementById(input: UpdateAnnouncementInput!): AnnouncementModel!
deleteAnnouncementById(id: ID!): AnnouncementModel!
deleteAnnouncements(ids: [ID!]!): BatchDeleteModel!
sendSMS(input: SendSMSInput!): SendSMSRes!
validateSMS(input: ValidateSMSInput!): ValidateSMSRes!
createOpenSource(input: CreateOpenSourceInput!): OpenSourceModel!
updateOpenSourceById(input: UpdateOpenSourceInput!): OpenSourceModel!
deleteOpenSourceById(id: ID!): OpenSourceModel!
deleteOpenSources(ids: [ID!]!): BatchDeleteModel!
createLiveTour(input: CreateLiveTourInput!): LiveTourModel!
updateLiveTourById(input: UpdateLiveTourInput!): LiveTourModel!
deleteLiveTourById(id: ID!): LiveTourModel!
deleteLiveTours(ids: [ID!]!): BatchDeleteModel!
createYanceyMusic(input: CreateYanceyMusicInput!): YanceyMusicModel!
updateYanceyMusicById(input: UpdateYanceyMusicInput!): YanceyMusicModel!
deleteYanceyMusicById(id: ID!): YanceyMusicModel!
deleteYanceyMusic(ids: [ID!]!): BatchDeleteModel!
createBestAlbum(input: CreateBestAlbumInput!): BestAlbumModel!
updateBestAlbumById(input: UpdateBestAlbumInput!): BestAlbumModel!
deleteBestAlbumById(id: ID!): BestAlbumModel!
deleteBestAlbums(ids: [ID!]!): BatchDeleteModel!
createPlayer(input: CreatePlayerInput!): PlayerModel!
updatePlayerById(input: UpdatePlayerInput!): PlayerModel!
deletePlayerById(id: ID!): PlayerModel!
deletePlayer(ids: [ID!]!): BatchDeleteModel!
offlinePlayers(ids: [ID!]!): BatchUpdateModel!
}

type OpenSourceModel {
_id: ID!
title: String!
description: String!
url: String!
posterUrl: String!
createdAt: String!
updatedAt: String!
}

type PlayerModel {
_id: ID!
title: String!
artist: String!
lrc: String!
coverUrl: String!
musicFileUrl: String!
isPublic: Boolean!
createdAt: String!
updatedAt: String!
}

type Query {
login(input: LoginInput!): AuthModel!
getAnnouncements: [AnnouncementModel!]!
getAnnouncementById(id: ID!): AnnouncementModel!
getAllSMS: [SMSModel!]!
getOpenSources: [OpenSourceModel!]!
getOpenSourceById(id: ID!): OpenSourceModel!
getBanwagonServiceInfo: ServiceInfoModel!
getBanwagonUsageStats: [UsageStatesModel!]!
getLiveTours: [LiveTourModel!]!
getLiveTourById(id: ID!): LiveTourModel!
getYanceyMusic: [YanceyMusicModel!]!
getYanceyMusicById(id: ID!): YanceyMusicModel!
getBestAlbums: [BestAlbumModel!]!
getBestAlbumById(id: ID!): BestAlbumModel!
getPlayer: [PlayerModel!]!
getPlayerById(id: ID!): PlayerModel!
}

input RegisterInput {
email: String!
username: String!
password: String!
}

input SendSMSInput {
phoneNumber: String!
}

type SendSMSRes {
verificationCode: String!
}

type ServiceInfoModel {
vm_type: String!
ve_status: String!
ve_mac1: String!
ve_used_disk_space_b: String!
is_cpu_throttled: String!
ssh_port: Float!
live_hostname: String!
load_average: String!
mem_available_kb: Float!
swap_total_kb: Float!
swap_available_kb: Float!
hostname: String!
node_ip: String!
node_alias: String!
node_location: String!
node_location_id: String!
node_datacenter: String!
location_ipv6_ready: Boolean!
plan: String!
plan_monthly_data: Float!
monthly_data_multiplier: Float!
plan_disk: Float!
plan_ram: Float!
plan_swap: Float!
plan_max_ipv6s: Float!
os: String!
email: String!
data_counter: Float!
data_next_reset: Float!
ip_addresses: [String!]!
private_ip_addresses: [String!]!
ip_nullroutes: [String!]!
iso1: String
iso2: String
available_isos: [String!]!
plan_private_network_available: Boolean!
location_private_network_available: Boolean!
rdns_api_available: Boolean!
ptr: String!
suspended: Boolean!
policy_violation: Boolean!
suspension_count: Float
max_abuse_points: Float!
error: Float!
veid: Float!
}

type SMSModel {
_id: String!
phoneNumber: String!
verificationCode: String!
createdAt: String!
updatedAt: String!
}

input UpdateAnnouncementInput {
id: String!
content: String!
}

input UpdateBestAlbumInput {
title: String!
artist: String!
coverUrl: String!
mvUrl: String!
releaseDate: String!
id: String!
}

input UpdateLiveTourInput {
title: String!
posterUrl: String!
showTime: String!
id: String!
}

input UpdateOpenSourceInput {
title: String!
description: String!
url: String!
posterUrl: String!
id: String!
}

input UpdatePlayerInput {
title: String!
artist: String!
lrc: String!
coverUrl: String!
musicFileUrl: String!
isPublic: Boolean!
id: String!
}

input UpdateYanceyMusicInput {
title: String!
soundCloudUrl: String!
posterUrl: String!
releaseDate: String!
id: String!
}

type UsageStatesModel {
timestamp: String!
network_in_bytes: String!
network_out_bytes: String!
disk_read_bytes: String!
cpu_usage: String!
}

input ValidateSMSInput {
phoneNumber: String!
verificationCode: String!
}

type ValidateSMSRes {
success: Boolean!
}

type YanceyMusicModel {
_id: ID!
title: String!
soundCloudUrl: String!
posterUrl: String!
releaseDate: String!
createdAt: String!
updatedAt: String!
}
8 changes: 4 additions & 4 deletions src/announcements/announcements.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,31 @@ export class AnnouncementsResolver {
}

@Mutation(() => AnnouncementModel)
// @UseGuards(GqlAuthGuard)
@UseGuards(GqlAuthGuard)
public async createAnnouncement(
@Args('input') input: CreateAnnouncementInput,
): Promise<AnnouncementModel> {
return this.announcementsService.create(input)
}

@Mutation(() => AnnouncementModel)
// @UseGuards(GqlAuthGuard)
@UseGuards(GqlAuthGuard)
public async updateAnnouncementById(
@Args('input') input: UpdateAnnouncementInput,
): Promise<AnnouncementModel> {
return this.announcementsService.update(input)
}

@Mutation(() => AnnouncementModel)
// @UseGuards(GqlAuthGuard)
@UseGuards(GqlAuthGuard)
public async deleteAnnouncementById(
@Args({ name: 'id', type: () => ID }) id: string,
): Promise<AnnouncementModel> {
return this.announcementsService.deleteOneById(id)
}

@Mutation(() => BatchDeleteModel)
// @UseGuards(GqlAuthGuard)
@UseGuards(GqlAuthGuard)
public async deleteAnnouncements(@Args({ name: 'ids', type: () => [ID] }) ids: string[]) {
return this.announcementsService.batchDelete(ids)
}
Expand Down
8 changes: 4 additions & 4 deletions src/open-sources/open-sources.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@ export class OpenSourcesResolver {
}

@Mutation(() => OpenSourceModel)
// @UseGuards(GqlAuthGuard)
@UseGuards(GqlAuthGuard)
public async createOpenSource(@Args('input') input: CreateOpenSourceInput) {
return this.openSourcesService.create(input)
}

@Mutation(() => OpenSourceModel)
// @UseGuards(GqlAuthGuard)
@UseGuards(GqlAuthGuard)
public async updateOpenSourceById(@Args('input') input: UpdateOpenSourceInput) {
return this.openSourcesService.update(input)
}

@Mutation(() => OpenSourceModel)
// @UseGuards(GqlAuthGuard)
@UseGuards(GqlAuthGuard)
public async deleteOpenSourceById(@Args({ name: 'id', type: () => ID }) id: string) {
return this.openSourcesService.deleteOneById(id)
}

@Mutation(() => BatchDeleteModel)
// @UseGuards(GqlAuthGuard)
@UseGuards(GqlAuthGuard)
public async deleteOpenSources(@Args({ name: 'ids', type: () => [ID] }) ids: string[]) {
return this.openSourcesService.batchDelete(ids)
}
Expand Down
1 change: 1 addition & 0 deletions test/announcements.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ describe('AnnouncementsController (e2e)', () => {
operationName: null,
query: createOneTypeDefs,
})
.set('Authorization', 'Bearer ' + '')
.expect(({ body }) => {
const testData: AnnouncementModel = body.data.createAnnouncement
id = testData._id
Expand Down

0 comments on commit fee7776

Please sign in to comment.