package com.xinelu.applet.controller.newapp;

import com.xinelu.applet.service.newapp.NewAppLoginService;
import com.xinelu.common.core.domain.AjaxResult;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/newApp/login")
public class NewAppLoginController {

    @Resource
    private NewAppLoginService newAppLoginService;

    /**
     * 新app登录
     * @param personAccount
     * @param personPassword
     * @return
     */
    @PostMapping("/appLogin")
    public AjaxResult login(@RequestParam("personAccount") String personAccount, @RequestParam("personPassword") String personPassword) {
        if (StringUtils.isBlank(personAccount)) {
            return AjaxResult.error("请输入账号！");
        }
        if (StringUtils.isBlank(personPassword)) {
            return AjaxResult.error("请输入密码！");
        }
        return AjaxResult.success(newAppLoginService.login(personAccount, personPassword));
    }

    /**
     * 获取健康咨询-科室人员信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(newAppLoginService.selectHospitalPersonInfoById(id));
    }
}
