23 Commits

Author SHA1 Message Date
e8dc76ef82 【新增】新增显示教程详情
Some checks failed
CI Build and Test / build (pull_request) Has been cancelled
2025-10-30 09:36:39 +08:00
8aa6fc0abf 【优化】拦截地址 2025-10-30 09:36:09 +08:00
7eda1a85eb 【优化】使用Thymeleaf渲染 2025-10-30 09:35:46 +08:00
6a124a5754 【删除】教程展示测试文件 2025-10-30 09:34:03 +08:00
564e617802 【改进】模块化 2025-10-30 09:32:55 +08:00
3f09aa1238 【新增】模板引擎支持包 2025-10-30 09:31:24 +08:00
d28f358127 测试推送到全部分支
Some checks failed
CI Build and Test / build (pull_request) Has been cancelled
2025-10-29 18:26:22 +08:00
1cc52a113d 测试 2025-10-29 18:15:19 +08:00
c895e7364a 测试 2025-10-29 18:11:00 +08:00
5bb485c612 【新增】新增添加查看次数接口
Some checks failed
CI Build and Test / build (pull_request) Has been cancelled
2025-10-29 16:53:55 +08:00
4ceb96738e 【新增】颜色字段 2025-10-29 16:05:33 +08:00
f6bb392d49 【优化】优化自增id
Some checks failed
CI Build and Test / build (pull_request) Has been cancelled
2025-10-28 16:28:35 +08:00
53d3a88a1c 【优化】统一名称 2025-10-28 15:24:03 +08:00
577b37b768 【新增】数据国际化支持 2025-10-28 14:40:22 +08:00
e264cb15b9 【新增】排除教程接口未登录拦截 2025-10-28 13:51:49 +08:00
c18366836f 【新增】教程接口控制器 2025-10-28 13:51:19 +08:00
816396d9c0 【新增】教程与分类关联 2025-10-28 13:51:04 +08:00
4c66e875cf 【新增】教程分类 2025-10-28 13:50:41 +08:00
0df7f645a6 【新增】教程 2025-10-28 13:50:07 +08:00
ed2b7bfba6 新增后台管理
Some checks failed
CI Build and Test / build (push) Has been cancelled
Deploy to Server / build-and-deploy (push) Has been cancelled
2025-10-23 18:03:08 +08:00
6ab0508e8c 修改固件类型字段
Some checks failed
CI Build and Test / build (push) Has been cancelled
Deploy to Server / build-and-deploy (push) Has been cancelled
2025-10-23 11:40:44 +08:00
9fee94f90f Merge remote-tracking branch 'origin/main'
Some checks failed
CI Build and Test / build (push) Has been cancelled
Deploy to Server / build-and-deploy (push) Has been cancelled
2025-10-23 09:54:58 +08:00
6ca95b31fa 修改固件管理问题 2025-10-23 09:54:43 +08:00
41 changed files with 2371 additions and 74 deletions

View File

@@ -41,6 +41,7 @@ dependencies {
runtimeOnly 'com.mysql:mysql-connector-j' // MySQL 驱动
annotationProcessor 'org.projectlombok:lombok' // Lombok 注解处理
testImplementation 'org.springframework.boot:spring-boot-starter-test' // 测试框架
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' // thymeleaf模版引擎
}
tasks.named('test') {

View File

@@ -0,0 +1,252 @@
# 固件管理 API 接口文档
## 基本信息
- **Base URL**: `http://localhost:8080`
- **接口前缀**: `/firmware`
- **请求头**:
- `Accept-Language`: `zh_CN``en_US`(可选,默认中文)
## 统一响应格式
所有接口返回格式统一为:
```json
{
"code": 200,
"message": "操作成功",
"data": {},
"success": true
}
```
**字段说明:**
- `code`: 状态码200-成功500-失败)
- `message`: 提示消息(支持中英文国际化)
- `data`: 返回的数据
- `success`: 是否成功true/false
---
## 1. 根据ID查询固件
**接口描述:** 根据固件ID查询固件详细信息
**请求方式:** `GET`
**请求路径:** `/firmware/{id}`
**路径参数:**
| 参数名 | 类型 | 必填 | 说明 |
|--------|------|------|------|
| id | Long | 是 | 固件ID |
**请求示例:**
```bash
curl -X GET "http://localhost:8080/firmware/1" \
-H "Accept-Language: zh_CN"
```
**成功响应示例:**
```json
{
"code": 200,
"message": "操作成功",
"data": {
"id": 1,
"firmwareName": "固件 v2.0.0",
"firmwareSize": 2097152,
"firmwareDescription": "新版本固件,优化性能",
"firmwareType": "主控固件",
"downloadUrl": "https://example.com/firmware/v2.0.0.bin",
"createTime": "2025-01-15 10:30:00",
"updateTime": "2025-01-15 10:30:00"
},
"success": true
}
```
**失败响应示例:**
```json
{
"code": 500,
"message": "固件不存在",
"data": null,
"success": false
}
```
---
## 2. 分页查询固件列表
**接口描述:** 分页查询固件列表,支持按固件名称和固件类型筛选
**请求方式:** `GET`
**请求路径:** `/firmware/page`
**请求参数Query**
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|--------|------|------|--------|------|
| current | Long | 否 | 1 | 当前页码 |
| size | Long | 否 | 10 | 每页大小 |
| firmwareName | String | 否 | - | 固件名称(模糊查询) |
| firmwareType | String | 否 | - | 固件类型(精确查询) |
**请求示例:**
```bash
# 查询第1页每页10条
curl -X GET "http://localhost:8080/firmware/page?current=1&size=10" \
-H "Accept-Language: zh_CN"
# 按固件名称模糊查询
curl -X GET "http://localhost:8080/firmware/page?current=1&size=10&firmwareName=v2"
# 按固件类型查询
curl -X GET "http://localhost:8080/firmware/page?current=1&size=10&firmwareType=主控固件"
# 组合查询
curl -X GET "http://localhost:8080/firmware/page?current=1&size=10&firmwareName=v2&firmwareType=主控固件"
```
**成功响应示例:**
```json
{
"code": 200,
"message": "操作成功",
"data": {
"records": [
{
"id": 1,
"firmwareName": "固件 v2.0.0",
"firmwareSize": 2097152,
"firmwareDescription": "新版本固件,优化性能",
"firmwareType": "主控固件",
"downloadUrl": "https://example.com/firmware/v2.0.0.bin",
"createTime": "2025-01-15 10:30:00",
"updateTime": "2025-01-15 10:30:00"
},
{
"id": 2,
"firmwareName": "固件 v1.0.1",
"firmwareSize": 1049600,
"firmwareDescription": "修复了若干 bug 的版本",
"firmwareType": "主控固件",
"downloadUrl": "https://example.com/firmware/v1.0.1.bin",
"createTime": "2025-01-14 09:20:00",
"updateTime": "2025-01-14 09:20:00"
}
],
"total": 2,
"size": 10,
"current": 1,
"pages": 1
},
"success": true
}
```
**响应字段说明:**
- `records`: 当前页的数据列表
- `total`: 总记录数
- `size`: 每页大小
- `current`: 当前页码
- `pages`: 总页数
---
## 3. 查询所有固件
**接口描述:** 查询所有固件列表(不分页)
**请求方式:** `GET`
**请求路径:** `/firmware/list`
**请求示例:**
```bash
curl -X GET "http://localhost:8080/firmware/list" \
-H "Accept-Language: zh_CN"
```
**成功响应示例:**
```json
{
"code": 200,
"message": "操作成功",
"data": [
{
"id": 1,
"firmwareName": "固件 v2.0.0",
"firmwareSize": 2097152,
"firmwareDescription": "新版本固件,优化性能",
"firmwareType": "主控固件",
"downloadUrl": "https://example.com/firmware/v2.0.0.bin",
"createTime": "2025-01-15 10:30:00",
"updateTime": "2025-01-15 10:30:00"
},
{
"id": 2,
"firmwareName": "固件 v1.0.1",
"firmwareSize": 1049600,
"firmwareDescription": "修复了若干 bug 的版本",
"firmwareType": "主控固件",
"downloadUrl": "https://example.com/firmware/v1.0.1.bin",
"createTime": "2025-01-14 09:20:00",
"updateTime": "2025-01-14 09:20:00"
}
],
"success": true
}
```
---
## 错误码说明
| 错误码 | 说明 |
|--------|------|
| 200 | 请求成功 |
| 500 | 服务器内部错误 |
---
## 国际化支持
接口支持中英文双语,通过请求头 `Accept-Language``lang` 指定语言:
- `zh_CN` - 中文(默认)
- `en_US` - 英文
**示例:**
```bash
# 中文响应
curl -X GET "http://localhost:8080/firmware/1" \
-H "Accept-Language: zh_CN"
# 英文响应
curl -X GET "http://localhost:8080/firmware/1" \
-H "Accept-Language: en_US"
```
---
## 注意事项
1. **文件大小单位**`firmwareSize` 字段的单位是字节Byte
2. **时间格式**`createTime``updateTime` 的格式为 `yyyy-MM-dd HH:mm:ss`
3. **分页默认排序**:分页查询默认按创建时间倒序排列(最新的在前面)
4. **模糊查询**:分页查询中的 `firmwareName` 参数支持模糊匹配
5. **类型查询**:分页查询中的 `firmwareType` 参数是精确匹配
6. **国际化**:通过 `Accept-Language` 请求头可切换中英文响应消息

View File

@@ -23,10 +23,18 @@ public class SaTokenConfig implements WebMvcConfigurer {
.addPathPatterns("/**")
// 排除登录、注册、发送验证码接口
.excludePathPatterns("/user/login", "/user/register", "/user/sendCode")
// 排除后台管理登录接口
.excludePathPatterns("/sys/user/login")
// 排除反馈接口(支持匿名提交)
.excludePathPatterns("/feedback", "/feedback/**")
// 排除教程接口(支持匿名查询)
.excludePathPatterns("/tutorial", "/tutorial/**")
// 排除固件查询接口(不需要登录)
.excludePathPatterns("/firmware/**")
// 排除静态资源
.excludePathPatterns("/", "/index.html", "/*.html", "/*.css", "/*.js", "/*.ico", "/static/**")
.excludePathPatterns("/", "/loading.html", "/admin/login.html", "/*.css", "/*.js", "/*.ico", "/static/**")
// 排除后台管理静态资源
.excludePathPatterns("/admin/**")
// 排除 Druid 监控
.excludePathPatterns("/druid/**")
// 排除错误页面

View File

@@ -0,0 +1,20 @@
package com.corewing.app.dto;
import lombok.Data;
/**
* 后台管理登录请求参数
*/
@Data
public class SysLoginRequest {
/**
* 用户名
*/
private String username;
/**
* 密码
*/
private String password;
}

View File

@@ -43,7 +43,7 @@ public class Firmware implements Serializable {
/**
* 固件类型
*/
private String firmwareType;
private Integer firmwareType;
/**
* 固件下载地址

View File

@@ -0,0 +1,89 @@
package com.corewing.app.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 后台管理用户实体类
*/
@Data
@TableName("sys_user")
public class SysUser implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 用户ID
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 用户名
*/
private String username;
/**
* 密码(MD5加密)
*/
private String password;
/**
* 真实姓名
*/
private String realName;
/**
* 邮箱
*/
private String email;
/**
* 手机号
*/
private String telephone;
/**
* 头像URL
*/
private String avatar;
/**
* 最后登录IP
*/
private String loginIp;
/**
* 最后登录时间
*/
private LocalDateTime loginTime;
/**
* 状态0-禁用 1-启用
*/
private Integer status;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createTime;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
}

View File

@@ -0,0 +1,73 @@
package com.corewing.app.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* 教程
*/
@Data
@TableName("app_tutorial")
public class Tutorial implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 教程id
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 教程标题
*/
private String tutorialTitle;
/**
* 教程描述
*/
private String description;
/**
* 教程详情
*/
private String content;
/**
* 查看次数
*/
private Integer viewCount;
/**
* 推荐状态0不推荐1推荐
*/
private Integer recommendStatus;
/**
* 状态1正常2关闭
*/
private Integer status;
/**
* 语言中文zh英文en
*/
private String lang;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}

View File

@@ -0,0 +1,75 @@
package com.corewing.app.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* 教程分类
*/
@Data
@TableName("app_tutorial_category")
public class TutorialCategory implements Serializable {
/**
* 分类id
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 图标
*/
private String icon;
/**
* 颜色
*/
private String color;
/**
* 分类名称
*/
private String categoryTitle;
/**
* 分类描述
*/
private String description;
/**
* 类别category分类tag标签
*/
private String type;
/**
* 置首页0不置首1置首页
*/
private Integer firstStatus;
/**
* 状态1正常2关闭
*/
private Integer status;
/**
* 语言中文zh英文en
*/
private String lang;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}

View File

@@ -0,0 +1,35 @@
package com.corewing.app.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
/**
* 教程与分类关系实体
*/
@Data
@TableName("app_tutorial_category_relation")
public class TutorialCategoryRelation implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 教程id
*/
private Long TutorialId;
/**
* 教程分类id
*/
private Long CategoryId;
}

View File

@@ -0,0 +1,13 @@
package com.corewing.app.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.corewing.app.entity.SysUser;
import org.apache.ibatis.annotations.Mapper;
/**
* 后台管理用户 Mapper 接口
*/
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {
}

View File

@@ -0,0 +1,12 @@
package com.corewing.app.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.corewing.app.entity.TutorialCategory;
import org.apache.ibatis.annotations.Mapper;
/**
* 教程分类 Mapper接口
*/
@Mapper
public interface TutorialCategoryMapper extends BaseMapper<TutorialCategory> {
}

View File

@@ -0,0 +1,13 @@
package com.corewing.app.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.corewing.app.entity.TutorialCategoryRelation;
import org.apache.ibatis.annotations.Mapper;
/**
* 教程与教程分类关系Mapper接口
*/
@Mapper
public interface TutorialCategoryRelationMapper extends BaseMapper<TutorialCategoryRelation> {
}

View File

@@ -0,0 +1,17 @@
package com.corewing.app.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.corewing.app.entity.Tutorial;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 教程 Mapper 接口
*/
@Mapper
public interface TutorialMapper extends BaseMapper<Tutorial> {
Page<Tutorial> pageList(Page<Tutorial> page, @Param("categoryId") int categoryId, @Param("tutorialTitle") String tutorialTitle, @Param("lang") String lang);
}

View File

@@ -0,0 +1,24 @@
package com.corewing.app.modules.admin;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class SysMainController {
@GetMapping({"/", "/index.html"})
public String loading() {
return "/admin/loading";
}
@GetMapping("/admin/login.html")
public String login() {
return "/admin/login";
}
@GetMapping("/admin/index.html")
public String adminIndex() {
return "/admin/index";
}
}

View File

@@ -0,0 +1,76 @@
package com.corewing.app.modules.admin;
import cn.dev33.satoken.stp.StpUtil;
import com.corewing.app.common.Result;
import com.corewing.app.dto.SysLoginRequest;
import com.corewing.app.entity.SysUser;
import com.corewing.app.service.SysUserService;
import com.corewing.app.util.I18nUtil;
import com.corewing.app.util.IpUtil;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/**
* 后台管理用户 Controller
*/
@RestController
@RequestMapping("/sys/user")
public class SysUserController {
private final SysUserService sysUserService;
public SysUserController(SysUserService sysUserService) {
this.sysUserService = sysUserService;
}
/**
* 后台管理登录
*/
@PostMapping("/login")
public Result<Map<String, Object>> login(@RequestBody SysLoginRequest request, HttpServletRequest httpRequest) {
try {
// 获取登录IP
String loginIp = IpUtil.getClientIp(httpRequest);
// 执行登录
String token = sysUserService.login(request.getUsername(), request.getPassword(), loginIp);
// 查询用户信息
SysUser user = sysUserService.getByUsername(request.getUsername());
Map<String, Object> data = new HashMap<>();
data.put("token", token);
data.put("userId", user.getId());
data.put("username", user.getUsername());
data.put("realName", user.getRealName());
return Result.success(I18nUtil.getMessage("user.login.success"), data);
} catch (Exception e) {
return Result.error(e.getMessage());
}
}
/**
* 后台管理登出
*/
@PostMapping("/logout")
public Result<String> logout() {
StpUtil.logout();
return Result.success(I18nUtil.getMessage("user.logout.success"));
}
/**
* 获取当前登录用户信息
*/
@GetMapping("/info")
public Result<SysUser> getUserInfo() {
Long userId = StpUtil.getLoginIdAsLong();
SysUser user = sysUserService.getById(userId);
// 隐藏密码
user.setPassword(null);
return Result.success(user);
}
}

View File

@@ -1,4 +1,4 @@
package com.corewing.app.controller;
package com.corewing.app.modules.app;
import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;

View File

@@ -1,4 +1,4 @@
package com.corewing.app.controller;
package com.corewing.app.modules.app;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -23,68 +23,6 @@ public class FirmwareController {
this.firmwareService = firmwareService;
}
/**
* 新增固件
*/
@PostMapping
public Result<String> add(@RequestBody Firmware firmware) {
try {
// 检查固件名称是否已存在
Firmware existFirmware = firmwareService.getByFirmwareName(firmware.getFirmwareName());
if (existFirmware != null) {
return Result.error(I18nUtil.getMessage("firmware.name.exists"));
}
boolean success = firmwareService.save(firmware);
if (success) {
return Result.success(I18nUtil.getMessage("firmware.add.success"));
}
return Result.error(I18nUtil.getMessage("firmware.add.failed"));
} catch (Exception e) {
return Result.error(e.getMessage());
}
}
/**
* 删除固件
*/
@DeleteMapping("/{id}")
public Result<String> delete(@PathVariable Long id) {
try {
boolean success = firmwareService.removeById(id);
if (success) {
return Result.success(I18nUtil.getMessage("firmware.delete.success"));
}
return Result.error(I18nUtil.getMessage("firmware.delete.failed"));
} catch (Exception e) {
return Result.error(e.getMessage());
}
}
/**
* 更新固件
*/
@PutMapping
public Result<String> update(@RequestBody Firmware firmware) {
try {
// 检查固件名称是否与其他固件重复
if (StringUtils.hasText(firmware.getFirmwareName())) {
Firmware existFirmware = firmwareService.getByFirmwareName(firmware.getFirmwareName());
if (existFirmware != null && !existFirmware.getId().equals(firmware.getId())) {
return Result.error(I18nUtil.getMessage("firmware.name.exists"));
}
}
boolean success = firmwareService.updateById(firmware);
if (success) {
return Result.success(I18nUtil.getMessage("firmware.update.success"));
}
return Result.error(I18nUtil.getMessage("firmware.update.failed"));
} catch (Exception e) {
return Result.error(e.getMessage());
}
}
/**
* 根据ID查询固件
*/
@@ -140,4 +78,24 @@ public class FirmwareController {
java.util.List<Firmware> list = firmwareService.list();
return Result.success(list);
}
/**
* 根据类型查询固件版本
*
* @param firmwareType 固件类型
*/
@GetMapping("/type/{firmwareType}")
public Result<java.util.List<Firmware>> listByType(@PathVariable Integer firmwareType) {
if (firmwareType == null) {
return Result.error(I18nUtil.getMessage("firmware.type.required"));
}
QueryWrapper<Firmware> wrapper = new QueryWrapper<>();
wrapper.eq("firmware_type", firmwareType);
// 按版本号或创建时间倒序排列最新版本在前
wrapper.orderByDesc("create_time");
java.util.List<Firmware> list = firmwareService.list(wrapper);
return Result.success(list);
}
}

View File

@@ -1,4 +1,4 @@
package com.corewing.app.controller;
package com.corewing.app.modules.app;
import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;

View File

@@ -0,0 +1,111 @@
package com.corewing.app.modules.app;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.corewing.app.common.Result;
import com.corewing.app.entity.Tutorial;
import com.corewing.app.entity.TutorialCategory;
import com.corewing.app.service.TutorialCategoryService;
import com.corewing.app.service.TutorialService;
import com.corewing.app.util.I18nUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 教程接口
*/
@RequestMapping("/tutorial")
@Controller
@Slf4j
public class TutorialController {
private final TutorialService tutorialService;
private final TutorialCategoryService tutorialCategoryService;
public TutorialController(TutorialService tutorialService, TutorialCategoryService tutorialCategoryService) {
this.tutorialService = tutorialService;
this.tutorialCategoryService = tutorialCategoryService;
}
/**
* 跳转到界面查看教程详情
* @param tutorialId 教程id
* @param model 数据模型
* @return 详情页
*/
@GetMapping("/viewDetail/{tutorialId}")
public String viewDetail(@PathVariable Long tutorialId, ModelMap model) {
Tutorial tutorial = tutorialService.getById(tutorialId);
model.put("tutorial", tutorial);
return "/app/tutorial/viewDetail";
}
/**
* 添加查看次数
* @param tutorialId 教程id
* @return
*/
@GetMapping("/addViewCount")
@ResponseBody
public Result<String> addViewCount(@RequestParam Long tutorialId) {
Tutorial tutorial = tutorialService.getById(tutorialId);
if(tutorial == null) {
return Result.error();
}
tutorial.setViewCount(tutorial.getViewCount() + 1);
tutorialService.updateById(tutorial);
return Result.success();
}
/**
* 分类查询列表
*
* @param firstStatus 置首状态(选填)
*
*/
@GetMapping("/category")
@ResponseBody
public Result<List<TutorialCategory>> category(
@RequestParam(required = false, defaultValue = "0") Integer firstStatus
) {
log.info("当前语言环境:{}", I18nUtil.getCurrentLocale().getLanguage());
LambdaQueryWrapper<TutorialCategory> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(firstStatus != 0, TutorialCategory::getFirstStatus, firstStatus);
wrapper.eq(TutorialCategory::getLang, I18nUtil.getCurrentLocale().getLanguage());
List<TutorialCategory> list = tutorialCategoryService.list(wrapper);
return Result.success(list);
}
/**
* 分页查询教程列表
*
* @param current 当前页码
* @param size 每页数量
* @param categoryId 分类ID选填
* @param tutorialTitle 教程标题(选填)
*
*/
@GetMapping("/page")
@ResponseBody
public Result<IPage<Tutorial>> getPageList(
@RequestParam(defaultValue = "1") Long current,
@RequestParam(defaultValue = "10") Long size,
@RequestParam(required = false, defaultValue = "0") Integer categoryId,
@RequestParam(required = false) String tutorialTitle) {
try {
Page<Tutorial> page = new Page<>(current, size);
IPage<Tutorial> pageResult = tutorialService.pageList(page, categoryId, tutorialTitle, I18nUtil.getCurrentLocale().getLanguage());
return Result.success(pageResult);
} catch (Exception e) {
return Result.error(e.getMessage());
}
}
}

View File

@@ -1,4 +1,4 @@
package com.corewing.app.controller;
package com.corewing.app.modules.app;
import cn.dev33.satoken.stp.StpUtil;
import com.corewing.app.common.Result;

View File

@@ -0,0 +1,36 @@
package com.corewing.app.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.corewing.app.entity.SysUser;
/**
* 后台管理用户 Service 接口
*/
public interface SysUserService extends IService<SysUser> {
/**
* 根据用户名查询用户
*
* @param username 用户名
* @return 用户信息
*/
SysUser getByUsername(String username);
/**
* 后台用户登录
*
* @param username 用户名
* @param password 密码
* @param loginIp 登录IP
* @return token
*/
String login(String username, String password, String loginIp);
/**
* 更新登录信息
*
* @param userId 用户ID
* @param loginIp 登录IP
*/
void updateLoginInfo(Long userId, String loginIp);
}

View File

@@ -0,0 +1,7 @@
package com.corewing.app.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.corewing.app.entity.TutorialCategoryRelation;
public interface TutorialCategoryRelationService extends IService<TutorialCategoryRelation> {
}

View File

@@ -0,0 +1,7 @@
package com.corewing.app.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.corewing.app.entity.TutorialCategory;
public interface TutorialCategoryService extends IService<TutorialCategory> {
}

View File

@@ -0,0 +1,10 @@
package com.corewing.app.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.corewing.app.entity.Tutorial;
public interface TutorialService extends IService<Tutorial> {
IPage<Tutorial> pageList(Page<Tutorial> page, int categoryId, String tutorialTitle, String lang);
}

View File

@@ -0,0 +1,69 @@
package com.corewing.app.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.corewing.app.entity.SysUser;
import com.corewing.app.mapper.SysUserMapper;
import com.corewing.app.service.SysUserService;
import com.corewing.app.util.I18nUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;
import org.springframework.util.StringUtils;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
/**
* 后台管理用户 Service 实现类
*/
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
@Override
public SysUser getByUsername(String username) {
if (!StringUtils.hasText(username)) {
return null;
}
LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SysUser::getUsername, username);
return this.getOne(wrapper);
}
@Override
public String login(String username, String password, String loginIp) {
// 查询用户
SysUser user = getByUsername(username);
if (user == null) {
throw new RuntimeException(I18nUtil.getMessage("error.user.not.found"));
}
// 验证密码MD5加密
String encryptPassword = DigestUtils.md5DigestAsHex(password.getBytes(StandardCharsets.UTF_8));
System.out.println(encryptPassword);
if (!encryptPassword.equalsIgnoreCase(user.getPassword())) {
throw new RuntimeException(I18nUtil.getMessage("error.password.incorrect"));
}
// 检查用户状态
if (user.getStatus() == 0) {
throw new RuntimeException(I18nUtil.getMessage("error.account.disabled"));
}
// 更新登录信息
updateLoginInfo(user.getId(), loginIp);
// 登录成功,使用 Sa-Token 生成 token使用 sys 作为登录类型区分)
StpUtil.login(user.getId(), "sys");
return StpUtil.getTokenValue();
}
@Override
public void updateLoginInfo(Long userId, String loginIp) {
SysUser user = new SysUser();
user.setId(userId);
user.setLoginIp(loginIp);
user.setLoginTime(LocalDateTime.now());
this.updateById(user);
}
}

View File

@@ -0,0 +1,11 @@
package com.corewing.app.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.corewing.app.entity.TutorialCategoryRelation;
import com.corewing.app.mapper.TutorialCategoryRelationMapper;
import com.corewing.app.service.TutorialCategoryRelationService;
import org.springframework.stereotype.Service;
@Service
public class TutorialCategoryRelationServiceImpl extends ServiceImpl<TutorialCategoryRelationMapper, TutorialCategoryRelation> implements TutorialCategoryRelationService {
}

View File

@@ -0,0 +1,11 @@
package com.corewing.app.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.corewing.app.entity.TutorialCategory;
import com.corewing.app.mapper.TutorialCategoryMapper;
import com.corewing.app.service.TutorialCategoryService;
import org.springframework.stereotype.Service;
@Service
public class TutorialCategoryServiceImpl extends ServiceImpl<TutorialCategoryMapper, TutorialCategory> implements TutorialCategoryService {
}

View File

@@ -0,0 +1,24 @@
package com.corewing.app.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.corewing.app.entity.Tutorial;
import com.corewing.app.mapper.TutorialMapper;
import com.corewing.app.service.TutorialService;
import org.springframework.stereotype.Service;
@Service
public class TutorialServiceImpl extends ServiceImpl<TutorialMapper, Tutorial> implements TutorialService {
private final TutorialMapper tutorialMapper;
public TutorialServiceImpl(TutorialMapper tutorialMapper) {
this.tutorialMapper = tutorialMapper;
}
@Override
public IPage<Tutorial> pageList(Page<Tutorial> page, int categoryId, String tutorialTitle, String lang) {
return tutorialMapper.pageList(page, categoryId, tutorialTitle, lang);
}
}

View File

@@ -0,0 +1,58 @@
package com.corewing.app.vo;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class TutorialVO {
private Long id;
/**
* 教程标题
*/
private String tutorialTitle;
/**
* 教程描述
*/
private String description;
/**
* 教程详情
*/
private String content;
/**
* 查看次数
*/
private Integer viewCount;
/**
* 推荐状态0不推荐1推荐
*/
private Integer recommendStatus;
/**
* 状态1正常2关闭
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 教程分类名称
*/
private String categoryTitle;
}

View File

@@ -0,0 +1,44 @@
/*
Navicat Premium Dump SQL
Source Server : 120.24.204.180
Source Server Type : MySQL
Source Server Version : 80036 (8.0.36)
Source Host : 120.24.204.180:3306
Source Schema : app
Target Server Type : MySQL
Target Server Version : 80036 (8.0.36)
File Encoding : 65001
Date: 28/10/2025 13:46:26
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for app_tutorial
-- ----------------------------
DROP TABLE IF EXISTS `app_tutorial`;
CREATE TABLE `app_tutorial` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
`tutorial_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '教程标题',
`description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '教程描述',
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '教程详情',
`view_count` int DEFAULT '0' COMMENT '查看次数',
`recommend_status` int DEFAULT '0' COMMENT '推荐状态0不推荐1推荐',
`status` tinyint(1) DEFAULT '1' COMMENT '状态1正常2关闭',
`create_time` datetime NOT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='使用教程表';
-- ----------------------------
-- Records of app_tutorial
-- ----------------------------
BEGIN;
INSERT INTO `app_tutorial` (`id`, `tutorial_title`, `description`, `content`, `view_count`, `recommend_status`, `status`, `create_time`, `update_time`) VALUES (1, '快速开始指南', '了解酷翼应用的基本功能与布局,快速上手使用各项功能。', NULL, 0, 0, 1, '2025-10-28 12:03:52', NULL);
COMMIT;
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -0,0 +1,44 @@
/*
Navicat Premium Dump SQL
Source Server : 120.24.204.180
Source Server Type : MySQL
Source Server Version : 80036 (8.0.36)
Source Host : 120.24.204.180:3306
Source Schema : app
Target Server Type : MySQL
Target Server Version : 80036 (8.0.36)
File Encoding : 65001
Date: 28/10/2025 13:46:32
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for app_tutorial_category
-- ----------------------------
DROP TABLE IF EXISTS `app_tutorial_category`;
CREATE TABLE `app_tutorial_category` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
`icon` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '图标',
`category_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '分类名称',
`description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '分类描述',
`first_status` int NOT NULL DEFAULT '2' COMMENT '置首页1置首2不置首',
`type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '类别category分类tag标签',
`status` tinyint(1) DEFAULT '0' COMMENT '状态1正常2关闭',
`create_time` datetime NOT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='使用教程分类/标签表';
-- ----------------------------
-- Records of app_tutorial_category
-- ----------------------------
BEGIN;
INSERT INTO `app_tutorial_category` (`id`, `icon`, `category_title`, `description`, `first_status`, `type`, `status`, `create_time`, `update_time`) VALUES (1, NULL, '快速指南', NULL, 1, 'category', 1, '2025-10-28 12:06:03', NULL);
COMMIT;
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -0,0 +1,38 @@
/*
Navicat Premium Dump SQL
Source Server : 120.24.204.180
Source Server Type : MySQL
Source Server Version : 80036 (8.0.36)
Source Host : 120.24.204.180:3306
Source Schema : app
Target Server Type : MySQL
Target Server Version : 80036 (8.0.36)
File Encoding : 65001
Date: 28/10/2025 13:46:38
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for app_tutorial_category_relation
-- ----------------------------
DROP TABLE IF EXISTS `app_tutorial_category_relation`;
CREATE TABLE `app_tutorial_category_relation` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
`tutorial_id` bigint DEFAULT NULL COMMENT '教程id',
`category_id` bigint DEFAULT NULL COMMENT '教程分类id',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='教程与教程分类关系表';
-- ----------------------------
-- Records of app_tutorial_category_relation
-- ----------------------------
BEGIN;
INSERT INTO `app_tutorial_category_relation` (`id`, `tutorial_id`, `category_id`) VALUES (1, 1, 1);
COMMIT;
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -0,0 +1,27 @@
-- 后台管理用户表
DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
`username` VARCHAR(50) NOT NULL COMMENT '用户名',
`password` VARCHAR(100) NOT NULL COMMENT '密码(MD5加密)',
`real_name` VARCHAR(50) DEFAULT NULL COMMENT '真实姓名',
`email` VARCHAR(100) DEFAULT NULL COMMENT '邮箱',
`telephone` VARCHAR(20) DEFAULT NULL COMMENT '手机号',
`avatar` VARCHAR(255) DEFAULT NULL COMMENT '头像URL',
`login_ip` VARCHAR(50) DEFAULT NULL COMMENT '最后登录IP',
`login_time` DATETIME DEFAULT NULL COMMENT '最后登录时间',
`status` TINYINT(1) DEFAULT 1 COMMENT '状态0-禁用 1-启用',
`remark` VARCHAR(500) DEFAULT NULL COMMENT '备注',
`create_time` DATETIME DEFAULT NULL COMMENT '创建时间',
`update_time` DATETIME DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_username` (`username`),
KEY `idx_status` (`status`),
KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='后台管理用户表';
-- 插入默认管理员账号密码为admin123MD5加密后
INSERT INTO `sys_user` (`username`, `password`, `real_name`, `email`, `status`, `remark`)
VALUES
('admin', 'e10adc3949ba59abbe56e057f20f883e', '系统管理员', 'admin@corewing.com', 1, '超级管理员账号');

View File

@@ -140,3 +140,4 @@ firmware.delete.failed=Failed to delete firmware
firmware.update.success=Firmware updated successfully
firmware.update.failed=Failed to update firmware
firmware.not.found=Firmware not found
firmware.type.required=Firmware type is required

View File

@@ -140,3 +140,4 @@ firmware.delete.failed=固件删除失败
firmware.update.success=固件更新成功
firmware.update.failed=固件更新失败
firmware.not.found=固件不存在
firmware.type.required=固件类型不能为空

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.corewing.app.mapper.TutorialMapper">
<!-- 结果映射 -->
<resultMap id="VOResultMap" type="com.corewing.app.vo.TutorialVO">
<id column="id" property="id"/>
<result column="tutorial_title" property="tutorialTitle"/>
<result column="description" property="description"/>
<result column="content" property="content"/>
<result column="view_count" property="viewCount"/>
<result column="recommend_status" property="recommendStatus"/>
<result column="status" property="status"/>
<result column="category_title" property="categoryTitle"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<!-- 基础查询SQL片段 -->
<sql id="selectVOSql">
select c.*, cc.category_title
from app_tutorial c
left join app_tutorial_category_relation ccr on c.id = ccr.tutorial_id
left join app_tutorial_category cc on cc.id = ccr.category_id
</sql>
<!-- 分页查询 -->
<select id="pageList" resultMap="VOResultMap">
<include refid="selectVOSql"/>
<where>
c.status = 1
and c.lang = #{lang}
<if test="categoryId != null and categoryId != 0">
AND cc.id = #{categoryId}
</if>
<if test="tutorialTitle != null and tutorialTitle != ''">
AND c.tutorial_title like CONCAT('%', #{tutorialTitle}, '%')
</if>
</where>
ORDER BY c.recommend_status,c.create_time asc
</select>
</mapper>

View File

@@ -1,6 +0,0 @@
<html>
<body>
<h1>hello word!!!</h1>
<p>this is a html page</p>
</body>
</html>

View File

@@ -0,0 +1,494 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>后台管理系统</title>
<!-- Bootstrap 5 CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap Icons -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
<style>
:root {
--primary-color: #5B5FDE;
--secondary-color: #0EA5E9;
--accent-color: #FF6B6B;
--error-color: #F43F5E;
--success-color: #10B981;
--warning-color: #F59E0B;
--info-color: #3B82F6;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: #F3F4F6;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
/* 侧边栏样式 */
.sidebar {
min-height: 100vh;
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
color: white;
padding: 0;
position: fixed;
left: 0;
top: 0;
width: 180px;
box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}
.sidebar-header {
padding: 18px 12px;
text-align: center;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-header h4 {
font-size: 16px;
font-weight: 700;
margin: 0;
}
.sidebar-header i {
margin-right: 5px;
font-size: 16px;
}
.sidebar-menu {
padding: 12px 8px;
}
.sidebar .nav-link {
color: rgba(255, 255, 255, 0.85);
padding: 9px 10px;
border-radius: 8px;
margin: 3px 0;
transition: all 0.3s;
font-weight: 500;
font-size: 13px;
display: flex;
align-items: center;
}
.sidebar .nav-link i {
width: 18px;
font-size: 15px;
}
.sidebar .nav-link:hover {
background-color: rgba(255, 255, 255, 0.15);
color: white;
transform: translateX(5px);
}
.sidebar .nav-link.active {
background-color: rgba(255, 255, 255, 0.25);
color: white;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.sidebar-footer {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 12px 8px;
}
.btn-logout {
width: 100%;
padding: 9px;
background: rgba(255, 255, 255, 0.15);
border: 1px solid rgba(255, 255, 255, 0.3);
color: white;
border-radius: 8px;
font-weight: 600;
font-size: 13px;
transition: all 0.3s;
}
.btn-logout:hover {
background: rgba(255, 255, 255, 0.25);
transform: translateY(-2px);
}
/* 顶部导航栏 */
.navbar {
background-color: white;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
padding: 12px 25px;
}
.navbar-brand {
font-size: 18px;
font-weight: 700;
color: #1F2937;
}
.user-info {
display: flex;
align-items: center;
gap: 8px;
color: #4B5563;
font-weight: 500;
font-size: 14px;
}
.user-info i {
font-size: 20px;
color: var(--primary-color);
}
/* 主内容区 */
.main-content {
margin-left: 180px;
}
/* 内容区域 */
.content-wrapper {
padding: 25px;
}
/* 欢迎卡片 */
.welcome-card {
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
color: white;
border-radius: 16px;
padding: 35px;
margin-bottom: 25px;
box-shadow: 0 10px 30px rgba(91, 95, 222, 0.2);
position: relative;
overflow: hidden;
}
.welcome-card::before {
content: '';
position: absolute;
width: 250px;
height: 250px;
background: rgba(255, 255, 255, 0.1);
border-radius: 50%;
top: -80px;
right: -80px;
}
.welcome-card h2 {
font-size: 26px;
font-weight: 700;
margin-bottom: 10px;
position: relative;
z-index: 1;
}
.welcome-card p {
font-size: 15px;
opacity: 0.95;
position: relative;
z-index: 1;
}
/* 统计卡片 */
.stat-card {
background: white;
border-radius: 12px;
padding: 25px;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
transition: all 0.3s;
border: 1px solid #E5E7EB;
}
.stat-card:hover {
transform: translateY(-5px);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.stat-card i {
font-size: 40px;
opacity: 0.9;
margin-bottom: 12px;
}
.stat-card h3 {
font-size: 30px;
font-weight: 700;
margin: 12px 0 6px;
color: #1F2937;
}
.stat-card p {
color: #6B7280;
font-size: 13px;
margin: 0;
}
.stat-card.primary i { color: var(--primary-color); }
.stat-card.success i { color: var(--success-color); }
.stat-card.warning i { color: var(--warning-color); }
.stat-card.info i { color: var(--info-color); }
/* 页面标题 */
.page-title {
font-size: 24px;
font-weight: 700;
color: #1F2937;
margin-bottom: 20px;
}
/* 卡片容器 */
.card {
background: white;
border-radius: 12px;
border: 1px solid #E5E7EB;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.card-body {
padding: 25px;
}
/* 响应式 */
@media (max-width: 768px) {
.sidebar {
width: 100%;
position: relative;
min-height: auto;
}
.main-content {
margin-left: 0;
}
.sidebar-footer {
position: static;
margin-top: 15px;
}
.welcome-card {
padding: 25px;
}
.welcome-card h2 {
font-size: 20px;
}
.content-wrapper {
padding: 20px;
}
}
</style>
</head>
<body>
<div id="app">
<!-- 侧边栏 -->
<nav class="sidebar">
<div class="sidebar-header">
<h4>
<i class="bi bi-shield-lock-fill"></i>
CoreWing
</h4>
</div>
<div class="sidebar-menu">
<ul class="nav flex-column">
<li class="nav-item">
<a :class="['nav-link', currentPage === 'dashboard' ? 'active' : '']"
href="#"
@click.prevent="currentPage = 'dashboard'">
<i class="bi bi-speedometer2"></i>
仪表盘
</a>
</li>
<li class="nav-item">
<a :class="['nav-link', currentPage === 'users' ? 'active' : '']"
href="#"
@click.prevent="currentPage = 'users'">
<i class="bi bi-people-fill"></i>
用户管理
</a>
</li>
<li class="nav-item">
<a :class="['nav-link', currentPage === 'settings' ? 'active' : '']"
href="#"
@click.prevent="currentPage = 'settings'">
<i class="bi bi-gear-fill"></i>
系统设置
</a>
</li>
</ul>
</div>
<div class="sidebar-footer">
<button class="btn-logout" @click="handleLogout">
<i class="bi bi-box-arrow-right me-2"></i>
退出登录
</button>
</div>
</nav>
<!-- 主内容区 -->
<main class="main-content">
<!-- 顶部导航栏 -->
<nav class="navbar navbar-expand-lg navbar-light">
<div class="container-fluid">
<span class="navbar-brand">欢迎回来</span>
<div class="user-info">
<i class="bi bi-person-circle"></i>
<span>{{ userInfo.realName || userInfo.username }}</span>
</div>
</div>
</nav>
<!-- 内容区域 -->
<div class="content-wrapper">
<!-- 仪表盘 -->
<div v-if="currentPage === 'dashboard'">
<div class="welcome-card">
<h2>
<i class="bi bi-emoji-smile"></i>
你好,{{ userInfo.realName || userInfo.username }}
</h2>
<p class="mb-0 mt-2">欢迎使用 CoreWing 后台管理系统</p>
</div>
<div class="row">
<div class="col-md-4 mb-4">
<div class="stat-card primary">
<i class="bi bi-people-fill"></i>
<h3>1,234</h3>
<p>总用户数</p>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="stat-card success">
<i class="bi bi-file-earmark-text-fill"></i>
<h3>567</h3>
<p>文档数量</p>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="stat-card warning">
<i class="bi bi-graph-up"></i>
<h3>89%</h3>
<p>系统负载</p>
</div>
</div>
</div>
</div>
<!-- 用户管理 -->
<div v-if="currentPage === 'users'">
<h3 class="page-title">用户管理</h3>
<div class="card">
<div class="card-body">
<p>用户管理功能开发中...</p>
</div>
</div>
</div>
<!-- 系统设置 -->
<div v-if="currentPage === 'settings'">
<h3 class="page-title">系统设置</h3>
<div class="card">
<div class="card-body">
<p>系统设置功能开发中...</p>
</div>
</div>
</div>
</div>
</main>
</div>
<!-- Vue 3 -->
<script src="https://cdn.jsdelivr.net/npm/vue@3.3.4/dist/vue.global.prod.js"></script>
<!-- Axios -->
<script src="https://cdn.jsdelivr.net/npm/axios@1.4.0/dist/axios.min.js"></script>
<!-- Bootstrap 5 JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
const { createApp } = Vue;
createApp({
data() {
return {
userInfo: {
username: '',
realName: '',
userId: ''
},
currentPage: 'dashboard'
}
},
methods: {
async loadUserInfo() {
// 从 localStorage 获取用户信息
this.userInfo.username = localStorage.getItem('username') || '';
this.userInfo.realName = localStorage.getItem('realName') || '';
this.userInfo.userId = localStorage.getItem('userId') || '';
// 也可以从服务器获取最新的用户信息
const token = localStorage.getItem('token');
if (token) {
try {
axios.defaults.headers.common['satoken'] = token;
const response = await axios.get('/sys/user/info');
if (response.data.code === 200) {
const user = response.data.data;
this.userInfo.username = user.username;
this.userInfo.realName = user.realName || user.username;
this.userInfo.userId = user.id;
}
} catch (error) {
console.error('获取用户信息失败:', error);
}
}
},
async handleLogout() {
if (confirm('确定要退出登录吗?')) {
try {
const token = localStorage.getItem('token');
if (token) {
axios.defaults.headers.common['satoken'] = token;
await axios.post('/sys/user/logout');
}
} catch (error) {
console.error('退出登录失败:', error);
} finally {
// 清除本地存储
localStorage.clear();
// 跳转到登录页
window.location.href = '/admin/login.html';
}
}
},
checkLogin() {
const token = localStorage.getItem('token');
if (!token) {
// 未登录,跳转到登录页
window.location.href = '/admin/login.html';
}
}
},
mounted() {
// 检查登录状态
this.checkLogin();
// 加载用户信息
this.loadUserInfo();
}
}).mount('#app');
</script>
</body>
</html>

View File

@@ -0,0 +1,93 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CoreWing - 后台管理系统</title>
<style>
:root {
--primary-color: #5B5FDE;
--secondary-color: #0EA5E9;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
color: white;
}
.container {
text-align: center;
}
.logo {
font-size: 72px;
margin-bottom: 20px;
animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.05); }
}
h1 {
font-size: 48px;
font-weight: 700;
margin-bottom: 15px;
}
p {
font-size: 18px;
opacity: 0.9;
margin-bottom: 30px;
}
.loading {
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
font-size: 16px;
}
.spinner {
width: 20px;
height: 20px;
border: 3px solid rgba(255, 255, 255, 0.3);
border-top-color: white;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
</style>
<script>
// 自动跳转到后台登录页面
window.location.href = '/admin/login.html';
</script>
</head>
<body>
<div class="container">
<div class="logo">🚀</div>
<h1>CoreWing</h1>
<p>后台管理系统</p>
<div class="loading">
<div class="spinner"></div>
<span>正在跳转...</span>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,497 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>后台管理系统 - 登录</title>
<!-- Bootstrap 5 CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap Icons -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
<style>
:root {
--primary-color: #5B5FDE;
--secondary-color: #0EA5E9;
--accent-color: #FF6B6B;
--error-color: #F43F5E;
--success-color: #10B981;
--warning-color: #F59E0B;
--info-color: #3B82F6;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: linear-gradient(135deg, #5B5FDE 0%, #0EA5E9 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
padding: 20px;
position: relative;
overflow: hidden;
}
/* 背景装饰圆圈 */
body::before {
content: '';
position: absolute;
width: 500px;
height: 500px;
background: rgba(255, 255, 255, 0.1);
border-radius: 50%;
top: -200px;
right: -200px;
animation: float 6s ease-in-out infinite;
}
body::after {
content: '';
position: absolute;
width: 300px;
height: 300px;
background: rgba(255, 255, 255, 0.08);
border-radius: 50%;
bottom: -100px;
left: -100px;
animation: float 8s ease-in-out infinite;
}
@keyframes float {
0%, 100% { transform: translateY(0px) rotate(0deg); }
50% { transform: translateY(-20px) rotate(5deg); }
}
.login-container {
position: relative;
z-index: 1;
width: 100%;
max-width: 1800px;
display: flex;
background: white;
border-radius: 24px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
overflow: hidden;
}
/* 左侧装饰区域 */
.login-decoration {
flex: 0.9;
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
padding: 60px 50px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: white;
position: relative;
overflow: hidden;
}
.login-decoration::before {
content: '';
position: absolute;
width: 300px;
height: 300px;
background: rgba(255, 255, 255, 0.1);
border-radius: 50%;
top: -80px;
left: -80px;
}
.login-decoration::after {
content: '';
position: absolute;
width: 220px;
height: 220px;
background: rgba(255, 255, 255, 0.08);
border-radius: 50%;
bottom: -60px;
right: -60px;
}
.decoration-content {
position: relative;
z-index: 1;
text-align: center;
}
.decoration-icon {
font-size: 140px;
margin-bottom: 40px;
animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.05); }
}
.decoration-content h2 {
font-size: 42px;
font-weight: 700;
margin-bottom: 20px;
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.decoration-content p {
font-size: 18px;
opacity: 0.95;
line-height: 1.6;
}
/* 右侧表单区域 */
.login-form-section {
flex: 1.3;
padding: 60px 120px;
display: flex;
flex-direction: column;
justify-content: center;
}
.form-header {
margin-bottom: 40px;
}
.form-header h3 {
font-size: 32px;
font-weight: 700;
color: #1F2937;
margin-bottom: 12px;
}
.form-header p {
color: #6B7280;
font-size: 16px;
}
.form-group {
margin-bottom: 25px;
}
.form-label {
display: block;
font-size: 15px;
font-weight: 600;
color: #374151;
margin-bottom: 8px;
}
.input-wrapper {
position: relative;
}
.input-icon {
position: absolute;
left: 18px;
top: 50%;
transform: translateY(-50%);
color: var(--primary-color);
font-size: 20px;
z-index: 1;
}
.form-control {
width: 100%;
padding: 16px 18px 16px 52px;
border: 2px solid #E5E7EB;
border-radius: 12px;
font-size: 16px;
transition: all 0.3s;
background-color: #F9FAFB;
}
.form-control:focus {
outline: none;
border-color: var(--primary-color);
background-color: white;
box-shadow: 0 0 0 4px rgba(91, 95, 222, 0.1);
}
.form-control::placeholder {
color: #9CA3AF;
}
.btn-login {
width: 100%;
padding: 16px;
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
border: none;
border-radius: 12px;
color: white;
font-size: 17px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s;
box-shadow: 0 4px 15px rgba(91, 95, 222, 0.3);
}
.btn-login:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(91, 95, 222, 0.4);
}
.btn-login:active:not(:disabled) {
transform: translateY(0);
}
.btn-login:disabled {
opacity: 0.7;
cursor: not-allowed;
}
.alert {
padding: 14px 18px;
border-radius: 12px;
margin-bottom: 20px;
font-size: 15px;
display: flex;
align-items: center;
gap: 10px;
animation: slideDown 0.3s ease;
}
@keyframes slideDown {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.alert-success {
background-color: #D1FAE5;
color: var(--success-color);
border: 1px solid var(--success-color);
}
.alert-danger {
background-color: #FEE2E2;
color: var(--error-color);
border: 1px solid var(--error-color);
}
.alert i {
font-size: 18px;
}
.login-footer {
text-align: center;
margin-top: 30px;
padding-top: 20px;
border-top: 1px solid #E5E7EB;
}
.login-footer small {
color: #6B7280;
font-size: 14px;
}
.spinner-border {
width: 1.2rem;
height: 1.2rem;
border-width: 2px;
}
/* 响应式设计 */
@media (max-width: 768px) {
.login-decoration {
display: none;
}
.login-container {
max-width: 450px;
}
.login-form-section {
padding: 40px 30px;
}
}
</style>
</head>
<body>
<div id="app">
<div class="login-container">
<!-- 左侧装饰区域 -->
<div class="login-decoration">
<div class="decoration-content">
<div class="decoration-icon">
<i class="bi bi-shield-lock-fill"></i>
</div>
<h2>CoreWing</h2>
<p>后台管理系统</p>
<p style="margin-top: 20px; opacity: 0.85;">
安全 · 高效 · 智能
</p>
</div>
</div>
<!-- 右侧表单区域 -->
<div class="login-form-section">
<div class="form-header">
<h3>欢迎回来</h3>
<p>请登录您的账号以继续</p>
</div>
<!-- 提示消息 -->
<div v-if="message.text" :class="'alert alert-' + message.type" role="alert">
<i :class="'bi bi-' + (message.type === 'success' ? 'check-circle-fill' : 'exclamation-circle-fill')"></i>
<span>{{ message.text }}</span>
</div>
<!-- 登录表单 -->
<form @submit.prevent="handleLogin">
<div class="form-group">
<label class="form-label">用户名</label>
<div class="input-wrapper">
<i class="bi bi-person-fill input-icon"></i>
<input
type="text"
class="form-control"
v-model="loginForm.username"
placeholder="请输入用户名"
required
autocomplete="username">
</div>
</div>
<div class="form-group">
<label class="form-label">密码</label>
<div class="input-wrapper">
<i class="bi bi-lock-fill input-icon"></i>
<input
type="password"
class="form-control"
v-model="loginForm.password"
placeholder="请输入密码"
required
autocomplete="current-password">
</div>
</div>
<button
type="submit"
class="btn-login"
:disabled="loading">
<span v-if="loading">
<span class="spinner-border spinner-border-sm" role="status" style="margin-right: 8px;"></span>
登录中...
</span>
<span v-else>
<i class="bi bi-box-arrow-in-right" style="margin-right: 8px;"></i>
登录
</span>
</button>
</form>
<div class="login-footer">
<small>默认管理员账号admin / admin123</small>
</div>
</div>
</div>
</div>
<!-- Vue 3 -->
<script src="https://cdn.jsdelivr.net/npm/vue@3.3.4/dist/vue.global.prod.js"></script>
<!-- Axios -->
<script src="https://cdn.jsdelivr.net/npm/axios@1.4.0/dist/axios.min.js"></script>
<!-- Bootstrap 5 JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
const { createApp } = Vue;
createApp({
data() {
return {
loginForm: {
username: '',
password: ''
},
loading: false,
message: {
text: '',
type: 'success' // success, danger
}
}
},
methods: {
async handleLogin() {
// 表单验证
if (!this.loginForm.username || !this.loginForm.password) {
this.showMessage('请填写完整的登录信息', 'danger');
return;
}
this.loading = true;
this.message.text = '';
try {
const response = await axios.post('/sys/user/login', this.loginForm);
if (response.data.code === 200) {
// 登录成功
this.showMessage('登录成功,正在跳转...', 'success');
// 保存 token 和用户信息
localStorage.setItem('token', response.data.data.token);
localStorage.setItem('userId', response.data.data.userId);
localStorage.setItem('username', response.data.data.username);
localStorage.setItem('realName', response.data.data.realName || '');
// 2秒后跳转到主页
setTimeout(() => {
window.location.href = '/admin/index.html';
}, 2000);
} else {
// 登录失败
this.showMessage(response.data.message || '登录失败', 'danger');
}
} catch (error) {
console.error('登录错误:', error);
this.showMessage(
error.response?.data?.message || '登录失败,请稍后重试',
'danger'
);
} finally {
this.loading = false;
}
},
showMessage(text, type) {
this.message.text = text;
this.message.type = type;
// 3秒后自动清除消息错误消息
if (type === 'danger') {
setTimeout(() => {
this.message.text = '';
}, 3000);
}
}
},
mounted() {
// 检查是否已登录
const token = localStorage.getItem('token');
if (token) {
// 如果已有 token尝试跳转到主页
// window.location.href = '/admin/loading.html';
}
}
}).mount('#app');
</script>
</body>
</html>

View File

@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title th:text="${tutorial?.tutorialTitle}"></title>
</head>
<body>
</body>
</html>