//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.luozhihui.project.controller;

import com.luozhihui.project.common.ApiResponse;
import com.luozhihui.project.entity.Pact;
import com.luozhihui.project.mapper.PactShowMapper;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/api"})
@CrossOrigin
public class PactShowController {
    @Resource
    PactShowMapper pactShowMapper;

    public PactShowController() {
    }

    @PostMapping({"/AllPact"})
    public ApiResponse AllCar() {
        try {
            List<Pact> pact = this.pactShowMapper.FindAllPact();
            return pact != null ? new ApiResponse(pact, 200, "查询成功") : new ApiResponse((Object)null, 404, "未找到合同信息");
        } catch (Exception var2) {
            Exception e = var2;
            e.printStackTrace();
            return new ApiResponse((Object)null, 500, "服务器内部错误");
        }
    }

    @PostMapping({"/FindPactById"})
    public ApiResponse FindCarById(Pact pact) {
        try {
            List<Pact> pacts = this.pactShowMapper.FindPactById(pact.getUserId());
            return pacts != null && !pacts.isEmpty() ? new ApiResponse(pacts, 200, "查询成功") : new ApiResponse((Object)null, 404, "未找到合同信息");
        } catch (Exception var3) {
            Exception e = var3;
            e.printStackTrace();
            return new ApiResponse((Object)null, 500, "服务器内部错误");
        }
    }

    @PostMapping({"/FindPactByPactId"})
    public ApiResponse FindPactById(Pact pact) {
        try {
            List<Pact> pacts = this.pactShowMapper.FindPactByPactId(String.valueOf(pact.getPactId()));
            return pacts != null && !pacts.isEmpty() ? new ApiResponse(pacts, 200, "查询成功") : new ApiResponse((Object)null, 404, "未找到合同信息");
        } catch (Exception var3) {
            Exception e = var3;
            e.printStackTrace();
            return new ApiResponse((Object)null, 500, "服务器内部错误");
        }
    }
}
