260322:1648 Correct Coresspondence / Doing RFA / Correct CI
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { IsInt, IsNotEmpty, IsOptional, ValidateIf } from 'class-validator';
|
||||
import { IsInt, IsNotEmpty, IsOptional, _ValidateIf } from 'class-validator';
|
||||
|
||||
export class AssignRoleDto {
|
||||
@IsInt()
|
||||
|
||||
@@ -11,7 +11,7 @@ import { UpdatePreferenceDto } from './dto/update-preference.dto';
|
||||
export class UserPreferenceService {
|
||||
constructor(
|
||||
@InjectRepository(UserPreference)
|
||||
private prefRepo: Repository<UserPreference>,
|
||||
private prefRepo: Repository<UserPreference>
|
||||
) {}
|
||||
|
||||
// ดึง Preference ของ User (ถ้าไม่มีให้สร้าง Default)
|
||||
@@ -35,7 +35,7 @@ export class UserPreferenceService {
|
||||
// อัปเดต Preference
|
||||
async update(
|
||||
userId: number,
|
||||
dto: UpdatePreferenceDto,
|
||||
dto: UpdatePreferenceDto
|
||||
): Promise<UserPreference> {
|
||||
const pref = await this.findByUser(userId);
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import { Permission } from './entities/permission.entity';
|
||||
import { CreateUserDto } from './dto/create-user.dto';
|
||||
import { UpdateUserDto } from './dto/update-user.dto';
|
||||
import { SearchUserDto } from './dto/search-user.dto';
|
||||
import { Organization } from '../organization/entities/organization.entity';
|
||||
import { UuidResolverService } from '../../common/services/uuid-resolver.service';
|
||||
|
||||
@Injectable()
|
||||
@@ -242,14 +241,13 @@ export class UserService {
|
||||
}
|
||||
|
||||
// 2. ถ้าไม่มีใน Cache ให้ Query จาก DB (View: v_user_all_permissions)
|
||||
const permissions = await this.usersRepository.query(
|
||||
`SELECT permission_name FROM v_user_all_permissions WHERE user_id = ?`,
|
||||
[userId]
|
||||
);
|
||||
const permissions = await this.usersRepository.query<
|
||||
{ permission_name: string }[]
|
||||
>(`SELECT permission_name FROM v_user_all_permissions WHERE user_id = ?`, [
|
||||
userId,
|
||||
]);
|
||||
|
||||
const permissionList = permissions.map(
|
||||
(row: { permission_name: string }) => row.permission_name
|
||||
);
|
||||
const permissionList = permissions.map((row) => row.permission_name);
|
||||
|
||||
// 3. บันทึกลง Cache (TTL 1800 วินาที = 30 นาที)
|
||||
await this.cacheManager.set(cacheKey, permissionList, 1800 * 1000);
|
||||
|
||||
Reference in New Issue
Block a user