| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package service
- import (
- "Gwen/global"
- "Gwen/model"
- "gorm.io/gorm"
- )
- type AuditService struct {
- }
- func (as *AuditService) AuditConnList(page, pageSize uint, where func(tx *gorm.DB)) (res *model.AuditConnList) {
- res = &model.AuditConnList{}
- res.Page = int64(page)
- res.PageSize = int64(pageSize)
- tx := global.DB.Model(&model.AuditConn{})
- if where != nil {
- where(tx)
- }
- tx.Count(&res.Total)
- tx.Scopes(Paginate(page, pageSize))
- tx.Find(&res.AuditConns)
- return
- }
- // Create 创建
- func (as *AuditService) CreateAuditConn(u *model.AuditConn) error {
- res := global.DB.Create(u).Error
- return res
- }
- func (as *AuditService) DeleteAuditConn(u *model.AuditConn) error {
- return global.DB.Delete(u).Error
- }
- // Update 更新
- func (as *AuditService) UpdateAuditConn(u *model.AuditConn) error {
- return global.DB.Model(u).Updates(u).Error
- }
- // InfoByPeerIdAndConnId
- func (as *AuditService) InfoByPeerIdAndConnId(peerId string, connId int64) (res *model.AuditConn) {
- res = &model.AuditConn{}
- global.DB.Where("peer_id = ? and conn_id = ?", peerId, connId).First(res)
- return
- }
- // InfoById
- func (as *AuditService) InfoById(id uint) (res *model.AuditConn) {
- res = &model.AuditConn{}
- global.DB.Where("id = ?", id).First(res)
- return
- }
|