package com.malk.jiangshi.controller;

import com.malk.jiangshi.entity.Product;
import com.malk.jiangshi.service.JiangshiService;
import com.malk.server.common.McR;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@Slf4j
public class JiangshiController {
    @Autowired
    private JiangshiService jiangshiService;

    @GetMapping("/test")
    public McR test() {
        log.info("test");
        return McR.success();
    }


    @PostMapping("/addProduct")
    public McR addProduct(@RequestBody Product product) {
        log.info("addProduct");
        jiangshiService.addProduct(product);
        return McR.success();
    }

    @PostMapping("/updateProduct")
    public McR updateProduct(@RequestBody Map map) {
        log.info("updateProduct");
        jiangshiService.updateProduct(map);
        return McR.success();
    }
}
