package thyyxxk.webserver.controller.settings;

import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.settings.IntergrationMenu;
import thyyxxk.webserver.service.settings.MenuSettingsService;
import thyyxxk.webserver.utils.ResultVoUtil;

import java.util.List;

@RestController
@RequestMapping("/menuSettings")
public class MenuSettingsController {

    private final MenuSettingsService service;

    public MenuSettingsController(MenuSettingsService service) {
        this.service = service;
    }

    @GetMapping("/getMenuSettings")
    public ResultVo<List<IntergrationMenu>> getMenuSettings() {
        return ResultVoUtil.success(service.getMenuSettings());
    }

    @GetMapping("/getUserMenu")
    public ResultVo<List<IntergrationMenu>> getUserMenu() {
        return ResultVoUtil.success(service.getUserMenu());
    }

    @PostMapping("/updateMenuSettings")
    public ResultVo<String> updateMenuSettings(@RequestBody IntergrationMenu menuList) {
        return service.updateMenuSettings(menuList);
    }

    @GetMapping("/deleteMenuSettings")
    public ResultVo<String> deleteMenuSettings(@RequestParam("id") Integer id) {
        return service.deleteMenuSettings(id);
    }


}
