package cn.pluss.platform.controller;

import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.entity.MerchantQrcode;
import cn.pluss.platform.merchantQrcode.MerchantQrcodeService;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author djh
 */
@RestController
@RequestMapping("/merQrCode")
public class MerchantQrCodeController {

    @Setter(onMethod_ = {@Autowired})
    private MerchantQrcodeService merchantQrcodeService;

    @PostMapping("/saveMerQrcode")
    public Result<Object> saveMerQrcode(@RequestBody MerchantQrcode merchantQrcode) {
        merchantQrcodeService.saveMerQrcode(merchantQrcode);
        return ResultGenerator.genSuccessResult("二维码保存成功", null);
    }

    @GetMapping("/removeById/{userId}")
    public Result<Object> removeMerQrcode(@PathVariable("userId") String userId) {
        merchantQrcodeService.removeByUserId(userId);
        return ResultGenerator.genSuccessResult("二维码信息清理成功", null);
    }
}
