package com.xinelu.applet.controller.personappletlogin;


import com.xinelu.applet.service.personappletlogin.PersonAppletLoginService;
import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.AjaxResult;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description 护理员微信小程序登录注册控制器
 * @Author zh
 * @Date 2023-03-30
 */
@RestController
@RequestMapping("/nurseApplet/personLogin")
public class PersonAppletLoginController extends BaseController {

    @Resource
    private PersonAppletLoginService personAppletLoginService;

    /**
     * 护理员根据登录凭证获取用户的登录信息
     *
     * @param loginCode 登录凭证
     * @param phoneCode 手机号凭证
     * @return 微信用户登录信息
     */
    @GetMapping("/getPersonWeChatUserInfo")
    public AjaxResult appletLogin(@RequestParam("loginCode") String loginCode, @Param("phoneCode") String phoneCode) {
        if (StringUtils.isBlank(loginCode)) {
            return AjaxResult.error("登录凭证编码不能为空！");
        }
        if (StringUtils.isBlank(phoneCode)) {
            return AjaxResult.error("获取手机号凭证不存在");
        }
        return personAppletLoginService.personAppletLogin(loginCode, phoneCode);
    }
}
