package com.iformall.controller.official;

import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxMallApply;
import com.iformall.domain.po.WxMsgValidationcode;
import com.iformall.service.WxMallApplyService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxMallApply")
public class WxMallApplyController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private WxMallApplyService wxMallApplyService;

    @PostMapping("add")
    public ResultData add(@RequestBody WxMallApply wxMallApply) {
        logger.debug("[" + getIpAddr() + "] WxMallApplyController::add");
        //Assert.notNull(wxMallApply.getName(), "角色名不能为空");
        //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
        return wxMallApplyService.saveOrUpdate(wxMallApply);

    }

    @GetMapping("/sendvalidationcode")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "type", value = "场景", dataType = "Integer", paramType = "query", required = true)})
    public ResultData sendvalidationcode(String phone, Integer type) {
        logger.debug("[" + getIpAddr() + "] WxMallApplyController::sendvalidationcode");
        WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode();
        wxMsgValidationcode.setTenantId("1");
        wxMsgValidationcode.setPhone(phone);
        wxMsgValidationcode.setType(type);
        return wxMallApplyService.sendvalidationcode(wxMsgValidationcode);
    }


}
