package api import ( "fmt" "github.com/gin-gonic/gin" "wireguard-ui/http/param" "wireguard-ui/http/response" "wireguard-ui/http/vo" "wireguard-ui/service" "wireguard-ui/utils" ) type DashboardApi struct{} func Dashboard() DashboardApi { return DashboardApi{} } // List // @description: 操作日志 // @receiver DashboardApi // @param c func (DashboardApi) List(c *gin.Context) { var p param.Page if err := c.ShouldBind(&p); err != nil { response.R(c).Validator(err) return } var loginUser *vo.User if loginUser = GetCurrentLoginUser(c); c.IsAborted() { return } data, total, err := service.Log().List(p, loginUser) if err != nil { response.R(c).FailedWithError(fmt.Errorf("获取操作日志失败: %v", err.Error())) return } response.R(c).Paginate(data, total, p.Current, p.Size) } // DailyPoetry // @description: 每日诗词 // @receiver DashboardApi // @param c func (DashboardApi) DailyPoetry(c *gin.Context) { data, err := utils.DailyPoetry().HitokotoPoetry() if err != nil { response.R(c).FailedWithError("获取失败") return } response.R(c).OkWithData(data) }