添加分类的controller

This commit is contained in:
2025-09-14 22:21:03 +08:00
parent d14b46d007
commit 7f24d65d76
94 changed files with 146 additions and 137 deletions

0
.gitignore vendored Normal file → Executable file
View File

0
HELP.md Normal file → Executable file
View File

0
LICENSE Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

View File

@@ -1,135 +0,0 @@
<template>
<div class="dashboard-container">
<!-- 欢迎横幅 -->
<el-card shadow="never" class="welcome-banner">
<div class="welcome-content">
<div class="welcome-text">
<h2>欢迎回来</h2>
<p>准备好开始您的下一次模拟面试了吗在这里管理您的题库不断提升面试技巧</p>
</div>
<img src="/src/assets/dashboard-hero.svg" alt="仪表盘插图" class="welcome-illustration" />
</div>
</el-card>
<!-- 功能导航 -->
<div class="feature-grid">
<router-link to="/interview" class="feature-card-link">
<el-card shadow="hover" class="feature-card">
<div class="card-content">
<el-icon class="card-icon" style="background-color: #ecf5ff; color: #409eff;"><ChatLineRound /></el-icon>
<div class="text-content">
<h3>开始模拟面试</h3>
<p>上传简历与AI进行实战演练</p>
</div>
</div>
</el-card>
</router-link>
<router-link to="/question-bank" class="feature-card-link">
<el-card shadow="hover" class="feature-card">
<div class="card-content">
<el-icon class="card-icon" style="background-color: #f0f9eb; color: #67c23a;"><MessageBox /></el-icon>
<div class="text-content">
<h3>题库管理</h3>
<p>新增编辑和导入您的面试题库</p>
</div>
</div>
</el-card>
</router-link>
<router-link to="/history" class="feature-card-link">
<el-card shadow="hover" class="feature-card">
<div class="card-content">
<el-icon class="card-icon" style="background-color: #fdf6ec; color: #e6a23c;"><Finished /></el-icon>
<div class="text-content">
<h3>面试历史</h3>
<p>查看过往的面试记录与AI复盘报告</p>
</div>
</div>
</el-card>
</router-link>
</div>
</div>
</template>
<script setup>
// 导入Element Plus图标
import { ChatLineRound, MessageBox, Finished } from '@element-plus/icons-vue';
</script>
<style scoped>
/* 仪表盘容器 */
.dashboard-container {
padding: 10px;
}
/* 欢迎横幅 */
.welcome-banner {
border: none;
margin-bottom: 20px;
}
.welcome-content {
display: flex;
justify-content: space-between;
align-items: center;
}
.welcome-text h2 {
font-size: 1.8em;
margin-top: 0;
color: #303133;
}
.welcome-text p {
color: #606266;
font-size: 1.1em;
}
.welcome-illustration {
width: 200px;
height: auto;
}
/* 功能网格布局 */
.feature-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 20px;
}
.feature-card-link {
text-decoration: none;
}
.feature-card .card-content {
display: flex;
align-items: center;
padding: 20px;
transition: transform 0.3s, box-shadow 0.3s;
}
.feature-card:hover {
transform: translateY(-5px);
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}
.card-icon {
font-size: 32px;
padding: 15px;
border-radius: 50%;
margin-right: 20px;
}
.text-content h3 {
margin: 0 0 8px 0;
color: #303133;
font-size: 1.1em;
}
.text-content p {
margin: 0;
color: #909399;
font-size: 0.9em;
}
</style>

0
mvnw vendored Normal file → Executable file
View File

0
mvnw.cmd vendored Normal file → Executable file
View File

0
pom.xml Normal file → Executable file
View File

0
sql/.idea/.gitignore generated vendored Normal file → Executable file
View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

0
src/main/java/com/qingqiu/interview/common/res/R.java Normal file → Executable file
View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

@@ -1,15 +1,159 @@
package com.qingqiu.interview.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qingqiu.interview.common.res.R;
import com.qingqiu.interview.dto.QuestionCategoryDTO;
import com.qingqiu.interview.dto.QuestionCategoryPageParams;
import com.qingqiu.interview.entity.QuestionCategory;
import com.qingqiu.interview.service.IQuestionCategoryService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Slf4j
@RestController
@RequestMapping("/api/v1/question-category")
@RequiredArgsConstructor
public class QuestionCategoryController {
private final IQuestionCategoryService questionCategoryService;
/**
* 获取分类树列表
*/
@GetMapping("/tree-list")
public R<List<QuestionCategory>> getTreeList() {
try {
List<QuestionCategory> list = questionCategoryService.getTreeList();
return R.success(list);
} catch (Exception e) {
log.error("获取分类树列表失败", e);
return R.error("获取分类树列表失败");
}
}
/**
* 获取分类选项
*/
@GetMapping("/options")
public R<List<QuestionCategory>> getOptions() {
try {
List<QuestionCategory> options = questionCategoryService.getOptions();
return R.success(options);
} catch (Exception e) {
log.error("获取分类选项失败", e);
return R.error("获取分类选项失败");
}
}
/**
* 获取分类详情
*/
@GetMapping("/{id}")
public R<QuestionCategory> getDetail(@PathVariable Long id) {
try {
QuestionCategory category = questionCategoryService.getCategoryDetail(id);
return R.success(category);
} catch (Exception e) {
log.error("获取分类详情失败", e);
return R.error("获取分类详情失败");
}
}
/**
* 分页查询分类
*/
@GetMapping("/page")
public R<Page<QuestionCategory>> getPage(QuestionCategoryPageParams query) {
try {
Page<QuestionCategory> pageR = questionCategoryService.getCategoryPage(query);
return R.success(pageR);
} catch (Exception e) {
log.error("分页查询分类失败", e);
return R.error("分页查询分类失败");
}
}
/**
* 创建分类
*/
@PostMapping
public R<Long> create(@Validated @RequestBody QuestionCategoryDTO dto) {
try {
Long id = questionCategoryService.createCategory(dto);
return R.success(id);
} catch (RuntimeException e) {
log.error("创建分类失败", e);
return R.error(e.getMessage());
} catch (Exception e) {
log.error("创建分类失败", e);
return R.error("创建分类失败");
}
}
/**
* 更新分类
*/
@PutMapping("/{id}")
public R<Void> update(@PathVariable Long id, @Validated @RequestBody QuestionCategoryDTO dto) {
try {
questionCategoryService.updateCategory(id, dto);
return R.success();
} catch (RuntimeException e) {
log.error("更新分类失败", e);
return R.error(e.getMessage());
} catch (Exception e) {
log.error("更新分类失败", e);
return R.error("更新分类失败");
}
}
/**
* 删除分类
*/
@DeleteMapping("/{id}")
public R<Void> delete(@PathVariable Long id) {
try {
questionCategoryService.deleteCategory(id);
return R.success();
} catch (RuntimeException e) {
log.error("删除分类失败", e);
return R.error(e.getMessage());
} catch (Exception e) {
log.error("删除分类失败", e);
return R.error("删除分类失败");
}
}
/**
* 更新分类状态
*/
@PatchMapping("/{id}/state")
public R<Void> updateState(@PathVariable Long id, @RequestParam Integer state) {
try {
questionCategoryService.updateState(id, state);
return R.success();
} catch (Exception e) {
log.error("更新分类状态失败", e);
return R.error("更新分类状态失败");
}
}
/**
* 搜索分类
*/
@GetMapping("/search")
public R<List<QuestionCategory>> search(@RequestParam String name) {
try {
List<QuestionCategory> res = questionCategoryService.searchByName(name);
return R.success(res);
} catch (Exception e) {
log.error("搜索分类失败", e);
return R.error("搜索分类失败");
}
}
}

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

0
src/main/resources/application.yml Normal file → Executable file
View File

0
src/main/resources/mapper/AIClientService.xml Normal file → Executable file
View File

0
src/main/resources/mapper/AiSessionLogMapper.xml Normal file → Executable file
View File

View File

0
src/main/resources/mapper/InterviewMessageMapper.xml Normal file → Executable file
View File

View File

0
src/main/resources/mapper/QuestionCategoryMapper.xml Normal file → Executable file
View File

0
src/main/resources/mapper/QuestionMapper.xml Normal file → Executable file
View File

0
src/main/resources/sql/schema.sql Normal file → Executable file
View File

View File