package com.ruoyi.web.controller.app;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.ValidGroup;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.ss.mchApply.domain.MchApplyBO;
import com.ruoyi.ss.mchApply.service.IMchApplyService;
import com.ruoyi.ss.mchApply.service.MchApplyValidator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wjh
 * 2024/4/29
 */
@Api(tags = "商家合作申请")
@RestController
@RequestMapping("/app/mchApply")
public class AppMchApplyController extends BaseController {

    @Autowired
    private IMchApplyService mchApplyService;

    @Autowired
    private MchApplyValidator mchApplyValidator;

    @ApiOperation("提交商家合作申请")
    @PostMapping("/submit")
    public AjaxResult submit(@RequestBody @Validated(ValidGroup.FrontCreate.class) MchApplyBO data) {
        data.setUserId(getUserId());
        data = data.filterCreateByApp();
        ServiceUtil.assertion(mchApplyValidator.preInsertByApp(data));
        return success(mchApplyService.insertMchApply(data));
    }

}
