package thyyxxk.webserver.controller.dictionary.wxservice;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.dictionary.wxservice.WxserviceScrollNews;
import thyyxxk.webserver.service.dictionary.wxservice.ScrollNewsService;
import thyyxxk.webserver.utils.ResultVoUtil;

import java.util.List;

@RestController
@RequestMapping("/scrollNews")
public class ScrollNewsController {
    private final ScrollNewsService service;

    @Autowired
    public ScrollNewsController(ScrollNewsService service) {
        this.service = service;
    }

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

    @GetMapping("/getById")
    public ResultVo<WxserviceScrollNews> getById(@RequestParam("id") Integer id) {
        return ResultVoUtil.success(service.getById(id));
    }

    @PostMapping("/update")
    public ResultVo<String> update(@RequestBody WxserviceScrollNews body) {
        return ResultVoUtil.success(service.update(body));
    }
}
