| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- 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
- }
- // ConnInfoById
- func (as *AuditService) ConnInfoById(id uint) (res *model.AuditConn) {
- res = &model.AuditConn{}
- global.DB.Where("id = ?", id).First(res)
- return
- }
- // FileInfoById
- func (as *AuditService) FileInfoById(id uint) (res *model.AuditFile) {
- res = &model.AuditFile{}
- global.DB.Where("id = ?", id).First(res)
- return
- }
- func (as *AuditService) AuditFileList(page, pageSize uint, where func(tx *gorm.DB)) (res *model.AuditFileList) {
- res = &model.AuditFileList{}
- res.Page = int64(page)
- res.PageSize = int64(pageSize)
- tx := global.DB.Model(&model.AuditFile{})
- if where != nil {
- where(tx)
- }
- tx.Count(&res.Total)
- tx.Scopes(Paginate(page, pageSize))
- tx.Find(&res.AuditFiles)
- return
- }
- // CreateAuditFile
- func (as *AuditService) CreateAuditFile(u *model.AuditFile) error {
- res := global.DB.Create(u).Error
- return res
- }
- func (as *AuditService) DeleteAuditFile(u *model.AuditFile) error {
- return global.DB.Delete(u).Error
- }
- // Update 更新
- func (as *AuditService) UpdateAuditFile(u *model.AuditFile) error {
- return global.DB.Model(u).Updates(u).Error
- }
- func (as *AuditService) BatchDeleteAuditConn(ids []uint) error {
- return global.DB.Where("id in (?)", ids).Delete(&model.AuditConn{}).Error
- }
- func (as *AuditService) BatchDeleteAuditFile(ids []uint) error {
- return global.DB.Where("id in (?)", ids).Delete(&model.AuditFile{}).Error
- }
|