package com.pqs9200.controller.advanced;

import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.advanced.EntityResultData;
import com.njcn.pojo.advanced.EnumCode;
import com.njcn.pojo.advanced.PicDataObj;
import com.njcn.service.advanced.DrawPicService;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
import com.njcn.utils.UtilPackageData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 javax.servlet.http.HttpServletRequest;
import java.util.List;

@RequestMapping("advanced")
@RestController
public class DrawPicControl {
    @Autowired
    private DrawPicService drawPicService;
    @Autowired
    private UserLogDetailService userLog;
    private static final Logger logger = LoggerFactory.getLogger(DrawPicControl.class);

    @PostMapping(value = "drawPicByGuid")
    public EntityResultData<List<PicDataObj>> drawPicByGuid(String arrayGuid, HttpServletRequest request) {
        try {
            userLog.getLog("查询波形分析", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
            return UtilPackageData.success(drawPicService.drawPicByGuid(arrayGuid));
        } catch (Exception e) {
            logger.error(e.toString(), this.getClass());
            userLog.getLog("查询波形分析", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
            return UtilPackageData.abnormal(EnumCode.ABNORMAL.getCode(), EnumCode.ABNORMAL.getDescription(), null);
        }
    }
}