mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-04-18 04:14:21 +08:00
[opt](headless)Deletion of chat model and database should record user.
This commit is contained in:
@@ -15,5 +15,5 @@ public interface ChatModelService {
|
||||
|
||||
ChatModel updateChatModel(ChatModel chatModel, User user);
|
||||
|
||||
void deleteChatModel(Integer id);
|
||||
void deleteChatModel(Integer id, User user);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,12 @@ public class ChatModelServiceImpl extends ServiceImpl<ChatModelMapper, ChatModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteChatModel(Integer id) {
|
||||
public void deleteChatModel(Integer id, User user) {
|
||||
ChatModel chatModel = getChatModel(id);
|
||||
if (!checkAdminPermission(user, chatModel)) {
|
||||
throw new RuntimeException("没有权限删除该大模型");
|
||||
}
|
||||
|
||||
removeById(id);
|
||||
}
|
||||
|
||||
@@ -103,4 +108,13 @@ public class ChatModelServiceImpl extends ServiceImpl<ChatModelMapper, ChatModel
|
||||
chatModelDO.setConfig(JsonUtil.toString(chatModel.getConfig()));
|
||||
return chatModelDO;
|
||||
}
|
||||
|
||||
private boolean checkAdminPermission(User user, ChatModel chatModel) {
|
||||
String admin = chatModel.getAdmin();
|
||||
if (user.isSuperAdmin()) {
|
||||
return true;
|
||||
}
|
||||
return admin != null && admin.equals(user.getName())
|
||||
|| chatModel.getCreatedBy().equals(user.getName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user