package cn.pluss.platform.controller;

import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.entity.MerchantGuide;
import cn.pluss.platform.merchantGuide.MerchantGuideService;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author djh
 */
@RestController
@RequestMapping("/merchantGuide")
public class MerchantGuideController {

    @Setter(onMethod_ = {@Autowired})
    private MerchantGuideService merchantGuideService;

    @GetMapping("/list")
    public Result<Object> list() {
        List<MerchantGuide> merchantGuideList = merchantGuideService.appList();
        return ResultGenerator.genSuccessResult(merchantGuideList);
    }

    @PostMapping("/save")
    public Result<Object> save(@RequestBody MerchantGuide entity) {
        merchantGuideService.appSave(entity);
        return ResultGenerator.genSuccessResult("保存成功", null);
    }

    @GetMapping("/del/{id}")
    public Result<Object> del(@PathVariable("id") Integer id) {
        merchantGuideService.appDel(id);
        return ResultGenerator.genSuccessResult("删除成功", null);
    }

    @PostMapping({"/choose"})
    public Result<Object> choose(@RequestBody MerchantGuide merchantGuide) {
        merchantGuideService.appChoose(merchantGuide);
        return ResultGenerator.genSuccessResult("操作成功", null);
    }
}
