6.16 5

七安。發表於2024-06-17
package com.example.controller;

import com.example.pojo.Policy;
import com.example.server.PolicyServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/policy")
public class PolicyController {
    @Autowired
    private PolicyServer policyServer;

    @GetMapping("/getAll")
    public List<Policy> getAll() {
        return policyServer.getAll();
    }

    @GetMapping("/getById")
    public String getById(@RequestParam("id") int id) {
        return policyServer.getById(id);
    }

    @GetMapping("/getByName")
    public List<Policy> getByName(@RequestParam("name") String name) {
        return policyServer.getByName(name);
    }

    @GetMapping("/getNation")
    public List<Policy> getNation() {
        return policyServer.getNation();
    }

    @GetMapping("/getHebei")
    public List<Policy> getHebei() {
        return policyServer.getHebei();
    }

    @GetMapping("/getWaisheng")
    public List<Policy> getWaisheng() {
        return policyServer.getWaisheng();
    }
}