12345678910111213141516171819202122232425262728 |
- package services
- import (
- "context"
- "eta/eta_task/models"
- "eta/eta_task/services/alarm_msg"
- "eta/eta_task/utils"
- "fmt"
- "time"
- )
- // ClearUserLoginLog 每天清理两个月前的用户登录日志
- func ClearUserLoginLog(cont context.Context) (err error) {
- defer func() {
- if err != nil {
- tips := fmt.Sprintf("用户登录日志清理, ClearUserLoginLog error: %s", err.Error())
- fmt.Println(tips)
- go alarm_msg.SendAlarmMsg(tips, 2)
- }
- }()
- preTime := time.Now().Local().AddDate(0, -2, 0).Format(utils.FormatDateTime)
- e := models.ClearSysUserLoginRecord(preTime)
- if e != nil {
- err = fmt.Errorf("ClearSysUserLoginRecord: %s", e.Error())
- }
- return
- }
|