package com.example.springip.lab2.controllers;

import com.example.springip.lab2.service.OperationService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OperationController {
    private final OperationService operationService;

    public OperationController( OperationService operationService) {
        this.operationService = operationService;
    }

    @GetMapping("/sum")
    public Object sum(@RequestParam String val1, @RequestParam String val2, @RequestParam String type) {

        return (Object) operationService.sum(val1, val2, type);
    }

    @GetMapping("/mul")
    public Object mul(@RequestParam String val1, @RequestParam Integer val2, @RequestParam String type) {

        return (Object) operationService.mul(val1, val2, type);
    }

    @GetMapping("/length")
    public Object length(@RequestParam String val1, @RequestParam String type) {

        return (Object) operationService.length(val1, type);
    }

    @GetMapping("/startsWith")
    public Object startsWith(@RequestParam String val1, @RequestParam String val2, @RequestParam String type) {

        return (Object) operationService.startsWith(val1, val2, type);
    }



}
