feat(authorization): add skipAssessment option to admin grant APIs
Admin grant APIs now default to requiring assessment (benefitActive=false). Added optional skipAssessment parameter to bypass assessment when needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
4d01bc5faa
commit
9378bf7570
|
|
@ -27,6 +27,7 @@ export class AdminAuthorizationController {
|
|||
dto.communityName,
|
||||
user.userId,
|
||||
user.accountSequence,
|
||||
dto.skipAssessment ?? false,
|
||||
)
|
||||
await this.applicationService.grantCommunity(command)
|
||||
return { message: '社区授权成功' }
|
||||
|
|
@ -47,6 +48,7 @@ export class AdminAuthorizationController {
|
|||
dto.provinceName,
|
||||
user.userId,
|
||||
user.accountSequence,
|
||||
dto.skipAssessment ?? false,
|
||||
)
|
||||
await this.applicationService.grantProvinceCompany(command)
|
||||
return { message: '正式省公司授权成功' }
|
||||
|
|
@ -67,6 +69,7 @@ export class AdminAuthorizationController {
|
|||
dto.cityName,
|
||||
user.userId,
|
||||
user.accountSequence,
|
||||
dto.skipAssessment ?? false,
|
||||
)
|
||||
await this.applicationService.grantCityCompany(command)
|
||||
return { message: '正式市公司授权成功' }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { IsString, IsNotEmpty, MaxLength, IsNumber } from 'class-validator'
|
||||
import { ApiProperty } from '@nestjs/swagger'
|
||||
import { IsString, IsNotEmpty, MaxLength, IsNumber, IsBoolean, IsOptional } from 'class-validator'
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'
|
||||
|
||||
export class GrantCityCompanyDto {
|
||||
@ApiProperty({ description: '用户ID' })
|
||||
|
|
@ -23,4 +23,9 @@ export class GrantCityCompanyDto {
|
|||
@IsNotEmpty({ message: '城市名称不能为空' })
|
||||
@MaxLength(50, { message: '城市名称最大50字符' })
|
||||
cityName: string
|
||||
|
||||
@ApiPropertyOptional({ description: '是否跳过考核直接激活权益', default: false })
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
skipAssessment?: boolean
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { IsString, IsNotEmpty, MaxLength, IsNumber } from 'class-validator'
|
||||
import { ApiProperty } from '@nestjs/swagger'
|
||||
import { IsString, IsNotEmpty, MaxLength, IsNumber, IsBoolean, IsOptional } from 'class-validator'
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'
|
||||
|
||||
export class GrantCommunityDto {
|
||||
@ApiProperty({ description: '用户ID' })
|
||||
|
|
@ -17,4 +17,9 @@ export class GrantCommunityDto {
|
|||
@IsNotEmpty({ message: '社区名称不能为空' })
|
||||
@MaxLength(100, { message: '社区名称最大100字符' })
|
||||
communityName: string
|
||||
|
||||
@ApiPropertyOptional({ description: '是否跳过考核直接激活权益', default: false })
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
skipAssessment?: boolean
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { IsString, IsNotEmpty, MaxLength, IsNumber } from 'class-validator'
|
||||
import { ApiProperty } from '@nestjs/swagger'
|
||||
import { IsString, IsNotEmpty, MaxLength, IsNumber, IsBoolean, IsOptional } from 'class-validator'
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'
|
||||
|
||||
export class GrantProvinceCompanyDto {
|
||||
@ApiProperty({ description: '用户ID' })
|
||||
|
|
@ -23,4 +23,9 @@ export class GrantProvinceCompanyDto {
|
|||
@IsNotEmpty({ message: '省份名称不能为空' })
|
||||
@MaxLength(50, { message: '省份名称最大50字符' })
|
||||
provinceName: string
|
||||
|
||||
@ApiPropertyOptional({ description: '是否跳过考核直接激活权益', default: false })
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
skipAssessment?: boolean
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,5 +6,6 @@ export class GrantCityCompanyCommand {
|
|||
public readonly cityName: string,
|
||||
public readonly adminId: string,
|
||||
public readonly adminAccountSequence: number,
|
||||
public readonly skipAssessment: boolean = false,
|
||||
) {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,5 +5,6 @@ export class GrantCommunityCommand {
|
|||
public readonly communityName: string,
|
||||
public readonly adminId: string,
|
||||
public readonly adminAccountSequence: number,
|
||||
public readonly skipAssessment: boolean = false,
|
||||
) {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,5 +6,6 @@ export class GrantProvinceCompanyCommand {
|
|||
public readonly provinceName: string,
|
||||
public readonly adminId: string,
|
||||
public readonly adminAccountSequence: number,
|
||||
public readonly skipAssessment: boolean = false,
|
||||
) {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -232,6 +232,7 @@ export class AuthorizationApplicationService {
|
|||
userId,
|
||||
communityName: command.communityName,
|
||||
adminId,
|
||||
skipAssessment: command.skipAssessment,
|
||||
})
|
||||
|
||||
await this.authorizationRepository.save(authorization)
|
||||
|
|
@ -251,6 +252,7 @@ export class AuthorizationApplicationService {
|
|||
provinceCode: command.provinceCode,
|
||||
provinceName: command.provinceName,
|
||||
adminId,
|
||||
skipAssessment: command.skipAssessment,
|
||||
})
|
||||
|
||||
await this.authorizationRepository.save(authorization)
|
||||
|
|
@ -270,6 +272,7 @@ export class AuthorizationApplicationService {
|
|||
cityCode: command.cityCode,
|
||||
cityName: command.cityName,
|
||||
adminId,
|
||||
skipAssessment: command.skipAssessment,
|
||||
})
|
||||
|
||||
await this.authorizationRepository.save(authorization)
|
||||
|
|
|
|||
|
|
@ -221,7 +221,9 @@ export class AuthorizationRole extends AggregateRoot {
|
|||
userId: UserId
|
||||
communityName: string
|
||||
adminId: AdminUserId
|
||||
skipAssessment?: boolean
|
||||
}): AuthorizationRole {
|
||||
const skipAssessment = params.skipAssessment ?? false
|
||||
const auth = new AuthorizationRole({
|
||||
authorizationId: AuthorizationId.generate(),
|
||||
userId: params.userId,
|
||||
|
|
@ -238,10 +240,10 @@ export class AuthorizationRole extends AggregateRoot {
|
|||
assessmentConfig: AssessmentConfig.forCommunity(),
|
||||
requireLocalPercentage: 0,
|
||||
exemptFromPercentageCheck: true,
|
||||
benefitActive: true,
|
||||
benefitActivatedAt: new Date(),
|
||||
benefitActive: skipAssessment,
|
||||
benefitActivatedAt: skipAssessment ? new Date() : null,
|
||||
benefitDeactivatedAt: null,
|
||||
currentMonthIndex: 1,
|
||||
currentMonthIndex: skipAssessment ? 1 : 0,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
|
|
@ -306,7 +308,9 @@ export class AuthorizationRole extends AggregateRoot {
|
|||
provinceCode: string
|
||||
provinceName: string
|
||||
adminId: AdminUserId
|
||||
skipAssessment?: boolean
|
||||
}): AuthorizationRole {
|
||||
const skipAssessment = params.skipAssessment ?? false
|
||||
const auth = new AuthorizationRole({
|
||||
authorizationId: AuthorizationId.generate(),
|
||||
userId: params.userId,
|
||||
|
|
@ -323,10 +327,10 @@ export class AuthorizationRole extends AggregateRoot {
|
|||
assessmentConfig: AssessmentConfig.forProvince(),
|
||||
requireLocalPercentage: 0,
|
||||
exemptFromPercentageCheck: true,
|
||||
benefitActive: true,
|
||||
benefitActivatedAt: new Date(),
|
||||
benefitActive: skipAssessment,
|
||||
benefitActivatedAt: skipAssessment ? new Date() : null,
|
||||
benefitDeactivatedAt: null,
|
||||
currentMonthIndex: 0,
|
||||
currentMonthIndex: skipAssessment ? 1 : 0,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
|
|
@ -392,7 +396,9 @@ export class AuthorizationRole extends AggregateRoot {
|
|||
cityCode: string
|
||||
cityName: string
|
||||
adminId: AdminUserId
|
||||
skipAssessment?: boolean
|
||||
}): AuthorizationRole {
|
||||
const skipAssessment = params.skipAssessment ?? false
|
||||
const auth = new AuthorizationRole({
|
||||
authorizationId: AuthorizationId.generate(),
|
||||
userId: params.userId,
|
||||
|
|
@ -409,10 +415,10 @@ export class AuthorizationRole extends AggregateRoot {
|
|||
assessmentConfig: AssessmentConfig.forCity(),
|
||||
requireLocalPercentage: 0,
|
||||
exemptFromPercentageCheck: true,
|
||||
benefitActive: true,
|
||||
benefitActivatedAt: new Date(),
|
||||
benefitActive: skipAssessment,
|
||||
benefitActivatedAt: skipAssessment ? new Date() : null,
|
||||
benefitDeactivatedAt: null,
|
||||
currentMonthIndex: 0,
|
||||
currentMonthIndex: skipAssessment ? 1 : 0,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue