refactor: section update
This commit is contained in:
parent
405e7a508c
commit
f23cf5c93a
|
|
@ -192,7 +192,7 @@ export const updateSectionById = async (req, res) => {
|
|||
|
||||
if (NAME_SECTION && NAME_SECTION !== section.NAME_SECTION) {
|
||||
const existingSection = await models.Section.findOne({
|
||||
where: { NAME_SECTION },
|
||||
where: { NAME_SECTION, IS_DELETED: 0 },
|
||||
transaction,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ export const getTopicForAdmin = async (req, res) => {
|
|||
DESCRIPTION_TOPIC: {
|
||||
[models.Op.like]: `%${search}%`,
|
||||
},
|
||||
}
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
|
|
@ -204,7 +204,7 @@ export const createTopic = async (req, res) => {
|
|||
return response(
|
||||
409,
|
||||
null,
|
||||
"Topic with the same name already exists",
|
||||
"Topic with the same name already exists in this section",
|
||||
res
|
||||
);
|
||||
}
|
||||
|
|
@ -268,6 +268,23 @@ export const updateTopicById = async (req, res) => {
|
|||
}
|
||||
|
||||
if (NAME_TOPIC) {
|
||||
const existingTopic = await models.Topic.findOne({
|
||||
where: {
|
||||
ID_SECTION: ID_SECTION || topic.ID_SECTION,
|
||||
NAME_TOPIC,
|
||||
IS_DELETED: 0,
|
||||
},
|
||||
});
|
||||
|
||||
if (existingTopic && existingTopic.ID_TOPIC !== topic.ID_TOPIC) {
|
||||
return response(
|
||||
409,
|
||||
null,
|
||||
"Topic with the same name already exists in this section",
|
||||
res
|
||||
);
|
||||
}
|
||||
|
||||
topic.NAME_TOPIC = NAME_TOPIC;
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 87 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.7 KiB |
Loading…
Reference in New Issue
Block a user