登录控制器及其登录数据传输

master
xzy 8 months ago
parent 1977e2f614
commit af65bfedf6

@ -0,0 +1,77 @@
package com.example.api.controller;
// 导入登录日志实体类
import com.example.api.model.entity.LoginLog;
// 导入系统日志实体类
import com.example.api.model.entity.SystemLog;
// 导入响应结果类,用于统一返回格式
import com.example.api.model.support.ResponseResult;
// 导入系统日志视图对象,用于查询系统日志
import com.example.api.model.vo.SystemLogVo;
// 导入登录日志服务接口
import com.example.api.service.LoginLogService;
// 导入系统日志服务接口
import com.example.api.service.SystemLogService;
// 导入Spring框架的注解支持
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
// 导入Java的util包用于操作集合
import java.util.List;
// 导入Java的Map接口用于操作键值对集合
import java.util.Map;
// 使用RestController注解声明这是一个REST控制器
@RestController
// 使用RequestMapping注解指定这个控制器的基础URL路径
@RequestMapping("/api")
public class LogController {
// 使用@Autowired注解注入LoginLogService
@Autowired
private LoginLogService loginLogService;
// 使用@Autowired注解注入SystemLogService
@Autowired
private SystemLogService systemLogService;
// 使用GetMapping注解定义一个GET请求的处理器用于获取所有登录日志
@GetMapping("/loginlog")
public List<LoginLog> getLoginLog(){
// 调用loginLogService的getAll方法获取所有登录日志
List<LoginLog> all = loginLogService.getAll();
return all;
}
// 使用DeleteMapping注解定义一个DELETE请求的处理器用于删除指定ID的登录日志
@DeleteMapping("/loginlog")
public void delLoginLog(String id){
// 调用loginLogService的delLoginLog方法删除指定ID的登录日志
loginLogService.delLoginLog(id);
}
// 使用GetMapping注解定义一个GET请求的处理器用于获取所有系统日志
@GetMapping("/systemlog")
public List<SystemLog> getSystemLog(){
// 直接返回systemLogService的getAll方法获取的所有系统日志
return systemLogService.getAll();
}
// 使用DeleteMapping注解定义一个DELETE请求的处理器用于删除指定ID的系统日志
@DeleteMapping("/systemlog")
public void deleteSystemLogById(String id){
// 调用systemLogService的delete方法删除指定ID的系统日志
systemLogService.delete(id);
}
// 使用GetMapping注解定义一个GET请求的处理器用于根据条件查询系统日志
@GetMapping("/querySystemlog")
public List<SystemLog> querySystemlog(SystemLogVo systemLogVo){
// 打印传入的系统日志视图对象
System.out.println(systemLogVo);
// 调用systemLogService的query方法根据条件查询系统日志
return systemLogService.query(systemLogVo);
}
}
Loading…
Cancel
Save