package com.xinelu.applet.service.newapp.impl;

import com.xinelu.applet.mapper.newapp.NewAppLoginMapper;
import com.xinelu.applet.service.newapp.NewAppLoginService;
import com.xinelu.applet.vo.newapp.LoginStatusVo;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.manage.mapper.hospitalpersoninfo.HospitalPersonInfoMapper;
import com.xinelu.manage.vo.hospitalpersoninfo.HospitalPersonInfoVO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;

@Service
public class NewAppLoginServiceImpl implements NewAppLoginService {

    @Resource
    private NewAppLoginMapper newAppLoginMapper;
    @Resource
    private HospitalPersonInfoMapper hospitalPersonInfoMapper;

    /**
     * 新app登录
     * @param personAccount
     * @param personPassword
     * @return
     */
    @Override
    public AjaxResult login(String personAccount, String personPassword) {
        LoginStatusVo loginStatusVo = newAppLoginMapper.login(personAccount, personPassword);
        HashMap<String, String> hashMap = new HashMap<>();
        if (loginStatusVo.getCount()>0){
            hashMap.put("status",loginStatusVo.getStatus());
            hashMap.put("id",loginStatusVo.getId()+"");
            hashMap.put("str","登录成功！");
            return AjaxResult.success(hashMap);
        }else {
            return AjaxResult.error("账号或密码错误！");
        }
    }

    /**
     * 查询健康咨询-科室人员信息
     *
     * @param id 健康咨询-科室人员信息主键
     * @return 健康咨询-科室人员信息
     */
    @Override
    public HospitalPersonInfoVO selectHospitalPersonInfoById(Long id) {
        return hospitalPersonInfoMapper.selectHospitalPersonInfoById(id);
    }
}
