update log service
This commit is contained in:
@@ -7,35 +7,35 @@ import (
|
||||
)
|
||||
|
||||
type CronJobService struct {
|
||||
cronJobService dao.CronJobDao
|
||||
cronJobDao dao.CronJobDao
|
||||
}
|
||||
|
||||
// FindPage 分页查询数据
|
||||
func (s CronJobService) FindPage(query request.CronJobQuery) ([]entity.SysCronJob, int64) {
|
||||
return s.cronJobService.SelectPage(query)
|
||||
return s.cronJobDao.SelectPage(query)
|
||||
}
|
||||
|
||||
// Save 添加数据
|
||||
func (s CronJobService) Save(config entity.SysCronJob) int64 {
|
||||
return s.cronJobService.Insert(config)
|
||||
return s.cronJobDao.Insert(config)
|
||||
}
|
||||
|
||||
// GetInfo 查询数据
|
||||
func (s CronJobService) GetInfo(id int64) *entity.SysCronJob {
|
||||
return s.cronJobService.SelectById(id)
|
||||
return s.cronJobDao.SelectById(id)
|
||||
}
|
||||
|
||||
// GetInfo 查询数据
|
||||
func (s CronJobService) GetInfoByAlias(funcAlias string) *entity.SysCronJob {
|
||||
return s.cronJobService.SelectByFuncAlias(funcAlias)
|
||||
return s.cronJobDao.SelectByFuncAlias(funcAlias)
|
||||
}
|
||||
|
||||
// Edit 修改数据
|
||||
func (s CronJobService) Edit(config entity.SysCronJob) int64 {
|
||||
return s.cronJobService.Update(config)
|
||||
return s.cronJobDao.Update(config)
|
||||
}
|
||||
|
||||
// Remove 批量删除
|
||||
func (s CronJobService) Remove(list []int64) bool {
|
||||
return s.cronJobService.Delete(list)
|
||||
return s.cronJobDao.Delete(list)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/dao"
|
||||
"cutego/core/entity"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-basic/uuid"
|
||||
)
|
||||
|
||||
const CURRENT_UID_KEY = "CURRENT_LOG_UID"
|
||||
const DEFAULT_UID_KEY = "DEFAULT_LOG_UID"
|
||||
|
||||
type LogService struct {
|
||||
logDao dao.LogDao
|
||||
}
|
||||
|
||||
// FindPage 分页查询数据
|
||||
func (s LogService) FindPage(query request.LogQuery) ([]entity.SysLog, int64) {
|
||||
return s.logDao.SelectPage(query)
|
||||
}
|
||||
|
||||
// Save 添加数据
|
||||
func (s LogService) save(config entity.SysLog) int64 {
|
||||
return s.logDao.Insert(config)
|
||||
}
|
||||
|
||||
// LogToDB 记录日志
|
||||
func (s LogService) LogToDB(c *gin.Context, content string) {
|
||||
uid, exists := c.Get(CURRENT_UID_KEY)
|
||||
if !exists {
|
||||
uid = DEFAULT_UID_KEY
|
||||
}
|
||||
uidStr := uid.(string)
|
||||
s.save(entity.SysLog{Uid: uidStr, Content: content})
|
||||
}
|
||||
|
||||
// 开始记录日志前调用(只调用一次)
|
||||
func (s LogService) LogStart(c *gin.Context) {
|
||||
c.Set(CURRENT_UID_KEY, uuid.New())
|
||||
}
|
||||
Reference in New Issue
Block a user