| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package api
- import (
- request "Gwen/http/request/api"
- "Gwen/http/response"
- "Gwen/model"
- "Gwen/service"
- "github.com/gin-gonic/gin"
- "github.com/gin-gonic/gin/binding"
- "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
- }
- //fmt.Println(af)
- 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,
- }
- service.AllService.AuditService.UpdateAuditConn(up)
- }
- }
- response.Success(c, "")
- }
|