|
@@ -3,6 +3,7 @@ package service
|
|
|
import (
|
|
import (
|
|
|
"fmt"
|
|
"fmt"
|
|
|
"iot_manager_service/app/dao"
|
|
"iot_manager_service/app/dao"
|
|
|
|
|
+ "iot_manager_service/app/model"
|
|
|
"iot_manager_service/app/utils"
|
|
"iot_manager_service/app/utils"
|
|
|
"strconv"
|
|
"strconv"
|
|
|
"time"
|
|
"time"
|
|
@@ -29,7 +30,7 @@ func (s *operationHisService) Save(handleType, handleModuleType int, handleConte
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (s *operationHisService) List(handleContent, operationType, moduleType string, current,
|
|
func (s *operationHisService) List(handleContent, operationType, moduleType string, current,
|
|
|
- size int) ([]dao.OperationHis, *utils.Errors) {
|
|
|
|
|
|
|
+ size int) ([]model.OperationHisDetail, *utils.Errors) {
|
|
|
his := dao.OperationHis{
|
|
his := dao.OperationHis{
|
|
|
HandleContent: handleContent,
|
|
HandleContent: handleContent,
|
|
|
}
|
|
}
|
|
@@ -47,9 +48,23 @@ func (s *operationHisService) List(handleContent, operationType, moduleType stri
|
|
|
}
|
|
}
|
|
|
his.ModuleType = module
|
|
his.ModuleType = module
|
|
|
}
|
|
}
|
|
|
- list, err := his.GetHistories(current, size)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ offset := (current - 1) * size
|
|
|
|
|
+ limit := size
|
|
|
|
|
+ list, err := his.GetHistories(offset, limit)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return nil, utils.FailResponse(err.Error(), nil)
|
|
return nil, utils.FailResponse(err.Error(), nil)
|
|
|
}
|
|
}
|
|
|
- return list, nil
|
|
|
|
|
|
|
+ var details []model.OperationHisDetail
|
|
|
|
|
+ for _, his := range list {
|
|
|
|
|
+ detail := model.OperationHisDetail{
|
|
|
|
|
+ OperationHis: his,
|
|
|
|
|
+ }
|
|
|
|
|
+ uId, _ := strconv.ParseInt(his.HandleUserId, 10, 64)
|
|
|
|
|
+ detail.HandleName = utils.GetUserName(uId)
|
|
|
|
|
+ detail.OperationTypeName = utils.GetControlType(his.OperationType)
|
|
|
|
|
+ detail.ModuleTypeName = utils.GetModuleName(his.ModuleType)
|
|
|
|
|
+ details = append(details, detail)
|
|
|
|
|
+ }
|
|
|
|
|
+ return details, nil
|
|
|
}
|
|
}
|