| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- package api
- import (
- "github.com/gin-gonic/gin"
- "github.com/gin-gonic/gin/binding"
- request "github.com/lejianwen/rustdesk-api/http/request/api"
- "github.com/lejianwen/rustdesk-api/http/response"
- "github.com/lejianwen/rustdesk-api/model"
- "github.com/lejianwen/rustdesk-api/service"
- "time"
- )
- type Audit struct {
- }
- // AuditConn
- // @Tags 审计
- // @Summary 审计连接
- // @Description 审计连接
- // @Accept json
- // @Produce json
- // @Param body body request.AuditConnForm true "审计连接"
- // @Success 200 {string} string ""
- // @Failure 500 {object} response.Response
- // @Router /audit/conn [post]
- func (a *Audit) AuditConn(c *gin.Context) {
- af := &request.AuditConnForm{}
- err := c.ShouldBindBodyWith(af, binding.JSON)
- if err != nil {
- response.Error(c, response.TranslateMsg(c, "ParamsError")+err.Error())
- return
- }
- /*ttt := &gin.H{}
- c.ShouldBindBodyWith(ttt, binding.JSON)
- fmt.Println(ttt)*/
- ac := af.ToAuditConn()
- if af.Action == model.AuditActionNew {
- service.AllService.AuditService.CreateAuditConn(ac)
- } else if af.Action == model.AuditActionClose {
- ex := service.AllService.AuditService.InfoByPeerIdAndConnId(af.Id, af.ConnId)
- if ex.Id != 0 {
- ex.CloseTime = time.Now().Unix()
- service.AllService.AuditService.UpdateAuditConn(ex)
- }
- } else if af.Action == "" {
- ex := service.AllService.AuditService.InfoByPeerIdAndConnId(af.Id, af.ConnId)
- if ex.Id != 0 {
- up := &model.AuditConn{
- IdModel: model.IdModel{Id: ex.Id},
- FromPeer: ac.FromPeer,
- FromName: ac.FromName,
- SessionId: ac.SessionId,
- Type: ac.Type,
- }
- service.AllService.AuditService.UpdateAuditConn(up)
- }
- }
- response.Success(c, "")
- }
- // AuditFile
- // @Tags 审计
- // @Summary 审计文件
- // @Description 审计文件
- // @Accept json
- // @Produce json
- // @Param body body request.AuditFileForm true "审计文件"
- // @Success 200 {string} string ""
- // @Failure 500 {object} response.Response
- // @Router /audit/file [post]
- func (a *Audit) AuditFile(c *gin.Context) {
- aff := &request.AuditFileForm{}
- err := c.ShouldBindBodyWith(aff, binding.JSON)
- if err != nil {
- response.Error(c, response.TranslateMsg(c, "ParamsError")+err.Error())
- return
- }
- //ttt := &gin.H{}
- //c.ShouldBindBodyWith(ttt, binding.JSON)
- //fmt.Println(ttt)
- af := aff.ToAuditFile()
- service.AllService.AuditService.CreateAuditFile(af)
- response.Success(c, "")
- }
|