package com.prolog.rdc.tms.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.model.dto.FrontPageStatisticalDTO;
import com.prolog.rdc.tms.service.FrontPageService;
import com.prolog.rdc.tms.util.PublicMethods;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 首页控制层
 *
 * Company: 湖北普罗格科技股份有限公司
 *
 * @author zhangsj
 * @since 2022/7/15 10:56
 */
@RestController
@Api(tags = "首页控制层")
@RequestMapping("/frontPage")
public class FrontPageController {

    @Autowired
    private FrontPageService frontPageService;

    @UserLog("统计查询")
    @ApiOperation(value = "统计查询", notes = "统计查询")
    @PostMapping("/statistical")
    public RestMessage<FrontPageStatisticalDTO> statisticalExecute() {
        try {
            FrontPageStatisticalDTO dto = frontPageService.statisticalData();
            return RestMessage.newInstance(true, "查询成功！", dto);
        } catch (Exception e) {
            return RestMessage.newInstance(false, PublicMethods.getExceptionMessage(e), null);
        }
    }
}
