|
@@ -0,0 +1,46 @@
|
|
|
+package report
|
|
|
+
|
|
|
+import (
|
|
|
+ "errors"
|
|
|
+ "fmt"
|
|
|
+ "hongze/hongze_yb/global"
|
|
|
+ "hongze/hongze_yb/models/tables/user_access_record"
|
|
|
+ "hongze/hongze_yb/services/user"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+// AddUserAccessRecord 新增报告浏览记录
|
|
|
+func AddUserAccessRecord(params ...interface{}){
|
|
|
+ var err error
|
|
|
+ userInter := params[0]
|
|
|
+ userInfo, ok := (userInter).(user.UserInfo)
|
|
|
+ if !ok {
|
|
|
+ err = errors.New("格式换转失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ global.LOG.Critical(fmt.Sprintf("Task AddUserAccessRecord: userId=%d, err:%s", userInfo.UserID, err.Error()))
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ reportId := params[1].(int)
|
|
|
+ if reportId > 0 {
|
|
|
+ classifyName := params[2]
|
|
|
+ reportChapterId := params[3].(int)
|
|
|
+ authOk := params[4].(bool)
|
|
|
+ record := new(user_access_record.UserAccessRecord)
|
|
|
+ record.Uid = int(userInfo.UserID)
|
|
|
+ record.Token = userInfo.LoginToken
|
|
|
+ record.CreateTime = time.Now()
|
|
|
+ record.Remark = "2" // 无权限
|
|
|
+ if authOk {
|
|
|
+ record.Remark = "0"
|
|
|
+ }
|
|
|
+ record.ReportId = reportId
|
|
|
+ if classifyName == "晨报" || classifyName == "周报" {
|
|
|
+ record.ReportChapterId = reportChapterId
|
|
|
+ }
|
|
|
+ err = record.Create()
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|