refactor: 중복 로직 제거

This commit is contained in:
Dayoung 2025-08-04 14:26:59 +09:00
parent 94b5cd8ae4
commit 9c7bed853f

View File

@ -115,16 +115,6 @@ export class SurveySalesService {
switch (this.session?.role) {
case 'Admin':
if (this.session?.storeId) {
where.OR = [
{ AND: [{ STORE_ID: { equals: this.session.storeId } }] },
{ AND: [{ SUBMISSION_TARGET_ID: { equals: this.session.storeId } }, { SUBMISSION_STATUS: { equals: true } }] },
{ AND: [{ SUBMISSION_TARGET_NM: { equals: this.session.storeNm } }, { SUBMISSION_STATUS: { equals: true } }] },
]
} else {
where.AND.push({ REPRESENTATIVE_ID: { equals: this.session.userId } })
}
break
case 'Admin_Sub':
if (this.session?.storeId) {
where.OR = [
@ -391,9 +381,9 @@ export class SurveySalesService {
if (!survey || !session) return false
const roleChecks = {
T01: () => this.checkT01Role(survey, session.userId),
T01: () => this.checkT01Role(survey, session.userId, session.storeId),
Admin: () => this.checkAdminRole(survey, session.storeId, session.storeNm),
Admin_Sub: () => this.checkAdminSubRole(survey, session.storeId, session.storeNm),
Admin_Sub: () => this.checkAdminRole(survey, session.storeId, session.storeNm),
Partner: () => this.checkPartnerOrBuilderRole(survey, session.builderId, session.userId),
Builder: () => this.checkPartnerOrBuilderRole(survey, session.builderId, session.userId),
default: () => false,
@ -409,8 +399,8 @@ export class SurveySalesService {
* @param {any} survey
* @returns {boolean} (true: , false: )
*/
private checkT01Role(survey: any, userId: string | null): boolean {
if (survey.REPRESENTATIVE_ID === userId) {
private checkT01Role(survey: any, userId: string | null, storeId: string | null): boolean {
if (survey.REPRESENTATIVE_ID === userId || survey.STORE_ID === storeId) {
return true
}
return survey.SRL_NO !== '一時保存'
@ -431,21 +421,6 @@ export class SurveySalesService {
: survey.STORE_ID === storeId
}
/**
* @description Admin_Sub (2 - Musubi)
* - , user에게
*
* @param {any} survey
* @param {string | null} storeId ID
* @returns {boolean} (true: , false: )
*/
private checkAdminSubRole(survey: any, storeId: string | null, storeNm: string | null): boolean {
if (!storeId) return survey.REPRESENTATIVE_ID === this.session?.userId
return survey.SUBMISSION_STATUS
? survey.SUBMISSION_TARGET_ID === storeId || survey.SUBMISSION_TARGET_NM === storeNm || survey.STORE_ID === storeId
: survey.STORE_ID === storeId
}
/**
* @description Partner Builder
* -