mirror of
https://github.com/lejianwen/rustdesk-api.git
synced 2025-11-29 08:33:21 +00:00
82 lines
2.2 KiB
Go
82 lines
2.2 KiB
Go
package admin
|
|
|
|
import (
|
|
"Gwen/global"
|
|
"Gwen/http/request/admin"
|
|
"Gwen/http/response"
|
|
"Gwen/model"
|
|
"Gwen/service"
|
|
"github.com/gin-gonic/gin"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Audit struct {
|
|
}
|
|
|
|
// ConnList 列表
|
|
// @Tags 链接日志
|
|
// @Summary 链接日志列表
|
|
// @Description 链接日志列表
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param page query int false "页码"
|
|
// @Param page_size query int false "页大小"
|
|
// @Param peer_id query int false "目标设备"
|
|
// @Param from_peer query int false "来源设备"
|
|
// @Success 200 {object} response.Response{data=model.AuditConnList}
|
|
// @Failure 500 {object} response.Response
|
|
// @Router /admin/audit_conn/list [get]
|
|
// @Security token
|
|
func (a *Audit) ConnList(c *gin.Context) {
|
|
query := &admin.AuditQuery{}
|
|
if err := c.ShouldBindQuery(query); err != nil {
|
|
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")+err.Error())
|
|
return
|
|
}
|
|
res := service.AllService.AuditService.AuditConnList(query.Page, query.PageSize, func(tx *gorm.DB) {
|
|
if query.PeerId != "" {
|
|
tx.Where("peer_id like ?", "%"+query.PeerId+"%")
|
|
}
|
|
if query.FromPeer != "" {
|
|
tx.Where("from_peer like ?", "%"+query.FromPeer+"%")
|
|
}
|
|
})
|
|
response.Success(c, res)
|
|
}
|
|
|
|
// ConnDelete 删除
|
|
// @Tags 链接日志
|
|
// @Summary 链接日志删除
|
|
// @Description 链接日志删除
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param body body model.AuditConn true "链接日志信息"
|
|
// @Success 200 {object} response.Response
|
|
// @Failure 500 {object} response.Response
|
|
// @Router /admin/audit_conn/delete [post]
|
|
// @Security token
|
|
func (a *Audit) ConnDelete(c *gin.Context) {
|
|
f := &model.AuditConn{}
|
|
if err := c.ShouldBindJSON(f); err != nil {
|
|
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")+err.Error())
|
|
return
|
|
}
|
|
id := f.Id
|
|
errList := global.Validator.ValidVar(c, id, "required,gt=0")
|
|
if len(errList) > 0 {
|
|
response.Fail(c, 101, errList[0])
|
|
return
|
|
}
|
|
l := service.AllService.AuditService.InfoById(f.Id)
|
|
if l.Id > 0 {
|
|
err := service.AllService.AuditService.DeleteAuditConn(l)
|
|
if err == nil {
|
|
response.Success(c, nil)
|
|
return
|
|
}
|
|
response.Fail(c, 101, err.Error())
|
|
return
|
|
}
|
|
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
|
|
}
|