29 lines
816 B
Python
29 lines
816 B
Python
import logging
|
|
import traceback
|
|
from typing import Any
|
|
|
|
from apps.eps.services.statistic.service import EpsStatisticService
|
|
from django.http import HttpRequest, JsonResponse
|
|
from django.views import View
|
|
|
|
logger = logging.getLogger("mfss")
|
|
|
|
|
|
class EpsStatisticApiView(View):
|
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
super().__init__(*args, **kwargs)
|
|
self.service = EpsStatisticService()
|
|
|
|
def get(self, request: HttpRequest) -> JsonResponse:
|
|
try:
|
|
data = self.service.get_workers()
|
|
return JsonResponse(data)
|
|
except Exception:
|
|
logger.error(traceback.format_exc())
|
|
return {
|
|
"error": "server error",
|
|
"status": -100,
|
|
"total": 0,
|
|
"items": [],
|
|
}
|