package com.zjsgfa.project.zjsgfa.controller;

import com.zjsgfa.framework.web.controller.BaseController;
import com.zjsgfa.framework.web.domain.AjaxResult;
import com.zjsgfa.project.zjsgfa.domain.SjSjzlErrorLog;
import com.zjsgfa.project.zjsgfa.service.SjSjzlErrorLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.xml.ws.soap.Addressing;
import java.util.List;

/**
 * 设计资料解析错误日志
 */
@Slf4j
@RestController
@RequestMapping("/system/sjsjzl")
public class SjSjzlErrorLogController extends BaseController {
    @Autowired
    private SjSjzlErrorLogService sjSjzlErrorLogService;

    /**
     * 根据井号查询错误信息
     * @param jh
     * @return
     */
    @GetMapping("/listByJh/{jh}")
    public AjaxResult listByJh(@PathVariable Long jh) {
        try {
            List<SjSjzlErrorLog> dataList = sjSjzlErrorLogService.listByJh(jh);
            return AjaxResult.success(dataList);
        }catch (Exception e) {
            log.error(e.getMessage());
            return AjaxResult.error(e.getMessage());
        }
    }

    /**
     * 新增
     */
    @PostMapping
    public AjaxResult add(@RequestBody SjSjzlErrorLog sjSjzlErrorLog) {
        try {
            return toAjax(sjSjzlErrorLogService.add(sjSjzlErrorLog));
        } catch (Exception e) {
            log.error(e.getMessage());
            return error(e.getMessage());
        }
    }
}
