lightRecordService.go 731 B

12345678910111213141516171819202122232425262728
  1. package service
  2. import (
  3. "iot_manager_service/app/record/dao"
  4. "iot_manager_service/util/common"
  5. )
  6. var LightRecordService = new(lightRecordService)
  7. type lightRecordService struct{}
  8. func (s *lightRecordService) List(searchValue, start, end string, id int, current int, size int) ([]dao.LightRecord, int64, *common.Errors) {
  9. var record dao.LightRecord
  10. offset := (current - 1) * size
  11. limit := size
  12. records, total, err := record.GetRecords(offset, limit, start, end, searchValue, id)
  13. if err != nil {
  14. return nil, 0, common.FailResponse(err.Error(), nil)
  15. }
  16. return records, total, nil
  17. }
  18. func (s *lightRecordService) Detail(id int) (dao.LightRecord, error) {
  19. record := &dao.LightRecord{
  20. Id: id,
  21. }
  22. return record.Get()
  23. }