공통코드,REST API 회사별 분리
This commit is contained in:
@@ -604,12 +604,13 @@ export class CommonCodeService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 카테고리 중복 검사
|
||||
* 카테고리 중복 검사 (회사별)
|
||||
*/
|
||||
async checkCategoryDuplicate(
|
||||
field: "categoryCode" | "categoryName" | "categoryNameEng",
|
||||
value: string,
|
||||
excludeCategoryCode?: string
|
||||
excludeCategoryCode?: string,
|
||||
userCompanyCode?: string
|
||||
): Promise<{ isDuplicate: boolean; message: string }> {
|
||||
try {
|
||||
if (!value || !value.trim()) {
|
||||
@@ -655,6 +656,12 @@ export class CommonCodeService {
|
||||
break;
|
||||
}
|
||||
|
||||
// 회사별 필터링 (최고 관리자가 아닌 경우)
|
||||
if (userCompanyCode && userCompanyCode !== "*") {
|
||||
sql += ` AND company_code = $${paramIndex++}`;
|
||||
values.push(userCompanyCode);
|
||||
}
|
||||
|
||||
// 수정 시 자기 자신 제외
|
||||
if (excludeCategoryCode) {
|
||||
sql += ` AND category_code != $${paramIndex++}`;
|
||||
@@ -675,6 +682,10 @@ export class CommonCodeService {
|
||||
categoryNameEng: "카테고리 영문명",
|
||||
};
|
||||
|
||||
logger.info(
|
||||
`카테고리 중복 검사: ${field}=${value}, 회사=${userCompanyCode}, 중복=${isDuplicate}`
|
||||
);
|
||||
|
||||
return {
|
||||
isDuplicate,
|
||||
message: isDuplicate
|
||||
@@ -688,13 +699,14 @@ export class CommonCodeService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 코드 중복 검사
|
||||
* 코드 중복 검사 (회사별)
|
||||
*/
|
||||
async checkCodeDuplicate(
|
||||
categoryCode: string,
|
||||
field: "codeValue" | "codeName" | "codeNameEng",
|
||||
value: string,
|
||||
excludeCodeValue?: string
|
||||
excludeCodeValue?: string,
|
||||
userCompanyCode?: string
|
||||
): Promise<{ isDuplicate: boolean; message: string }> {
|
||||
try {
|
||||
if (!value || !value.trim()) {
|
||||
@@ -743,6 +755,12 @@ export class CommonCodeService {
|
||||
break;
|
||||
}
|
||||
|
||||
// 회사별 필터링 (최고 관리자가 아닌 경우)
|
||||
if (userCompanyCode && userCompanyCode !== "*") {
|
||||
sql += ` AND company_code = $${paramIndex++}`;
|
||||
values.push(userCompanyCode);
|
||||
}
|
||||
|
||||
// 수정 시 자기 자신 제외
|
||||
if (excludeCodeValue) {
|
||||
sql += ` AND code_value != $${paramIndex++}`;
|
||||
@@ -760,6 +778,10 @@ export class CommonCodeService {
|
||||
codeNameEng: "코드 영문명",
|
||||
};
|
||||
|
||||
logger.info(
|
||||
`코드 중복 검사: ${categoryCode}.${field}=${value}, 회사=${userCompanyCode}, 중복=${isDuplicate}`
|
||||
);
|
||||
|
||||
return {
|
||||
isDuplicate,
|
||||
message: isDuplicate
|
||||
|
||||
Reference in New Issue
Block a user