package ink.wgink.register.wechat.controller.app.api.official.account;

import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.register.wechat.service.miniapp.OfficialAccountRegisterPhoneVO;
import ink.wgink.register.wechat.service.official.account.IOfficialAccountRegisterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
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;

import java.util.Map;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: RegisterController
 * @Description: 注册
 * @Author: wanggeng
 * @Date: 2021/4/29 6:12 下午
 * @Version: 1.0
 */
@Api(tags = ISystemConstant.API_TAGS_WECHAT_PREFIX + "注册")
@RestController
@RequestMapping(ISystemConstant.WECHAT_PREFIX + "/register")
public class RegisterWechatController extends DefaultBaseController {

    @Autowired
    private IOfficialAccountRegisterService officialAccountRegisterService;

    @ApiOperation(value = "手机注册", notes = "手机注册，手机 + 用户验证码注册接口")
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @PostMapping("phone")
    @CheckRequestBodyAnnotation
    public synchronized SuccessResult phone(@RequestBody OfficialAccountRegisterPhoneVO officialAccountRegisterPhoneVO) throws Exception {
        Map<String, Object> params = requestParams();
        officialAccountRegisterService.registerPhone(officialAccountRegisterPhoneVO, params);
        return new SuccessResult();
    }

}
