|  | @ -1,228 +1,228 @@
 | 
												
													
														
															|  | package com.yihu.wlyy.web.common.account;
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | import com.yihu.wlyy.entity.doctor.profile.Doctor;
 |  | 
 | 
												
													
														
															|  | import com.yihu.wlyy.entity.login.LoginLog;
 |  | 
 | 
												
													
														
															|  | import com.yihu.wlyy.entity.patient.Patient;
 |  | 
 | 
												
													
														
															|  | import com.yihu.wlyy.entity.security.Token;
 |  | 
 | 
												
													
														
															|  | import com.yihu.wlyy.repository.security.TokenDao;
 |  | 
 | 
												
													
														
															|  | import com.yihu.wlyy.service.common.SMSService;
 |  | 
 | 
												
													
														
															|  | import com.yihu.wlyy.service.common.account.DoctorService;
 |  | 
 | 
												
													
														
															|  | import com.yihu.wlyy.service.common.account.PatientService;
 |  | 
 | 
												
													
														
															|  | import com.yihu.wlyy.service.common.account.RoleService;
 |  | 
 | 
												
													
														
															|  | import com.yihu.wlyy.service.common.account.TokenService;
 |  | 
 | 
												
													
														
															|  | import com.yihu.wlyy.service.common.login.LoginLogService;
 |  | 
 | 
												
													
														
															|  | import com.yihu.wlyy.util.DateUtil;
 |  | 
 | 
												
													
														
															|  | import com.yihu.wlyy.util.MD5;
 |  | 
 | 
												
													
														
															|  | import com.yihu.wlyy.util.RSAUtils;
 |  | 
 | 
												
													
														
															|  | import com.yihu.wlyy.util.SystemData;
 |  | 
 | 
												
													
														
															|  | import com.yihu.wlyy.web.BaseController;
 |  | 
 | 
												
													
														
															|  | import io.swagger.annotations.Api;
 |  | 
 | 
												
													
														
															|  | import io.swagger.annotations.ApiParam;
 |  | 
 | 
												
													
														
															|  | import org.apache.commons.lang3.StringUtils;
 |  | 
 | 
												
													
														
															|  | import org.json.JSONObject;
 |  | 
 | 
												
													
														
															|  | import org.patchca.color.SingleColorFactory;
 |  | 
 | 
												
													
														
															|  | import org.patchca.filter.predefined.*;
 |  | 
 | 
												
													
														
															|  | import org.patchca.service.ConfigurableCaptchaService;
 |  | 
 | 
												
													
														
															|  | import org.patchca.utils.encoder.EncoderHelper;
 |  | 
 | 
												
													
														
															|  | import org.springframework.beans.factory.annotation.Autowired;
 |  | 
 | 
												
													
														
															|  | import org.springframework.http.MediaType;
 |  | 
 | 
												
													
														
															|  | import org.springframework.stereotype.Controller;
 |  | 
 | 
												
													
														
															|  | import org.springframework.web.bind.annotation.RequestMapping;
 |  | 
 | 
												
													
														
															|  | import org.springframework.web.bind.annotation.RequestMethod;
 |  | 
 | 
												
													
														
															|  | import org.springframework.web.bind.annotation.RequestParam;
 |  | 
 | 
												
													
														
															|  | import org.springframework.web.bind.annotation.ResponseBody;
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | import javax.servlet.http.HttpServletRequest;
 |  | 
 | 
												
													
														
															|  | import javax.servlet.http.HttpServletResponse;
 |  | 
 | 
												
													
														
															|  | import javax.servlet.http.HttpSession;
 |  | 
 | 
												
													
														
															|  | import java.awt.*;
 |  | 
 | 
												
													
														
															|  | import java.io.IOException;
 |  | 
 | 
												
													
														
															|  | import java.util.*;
 |  | 
 | 
												
													
														
															|  | import java.util.List;
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | //package com.yihu.wlyy.web.common.account;
 | 
												
													
														
															|  | 
 |  | //
 | 
												
													
														
															|  | 
 |  | //import com.yihu.wlyy.entity.doctor.profile.Doctor;
 | 
												
													
														
															|  | 
 |  | //import com.yihu.wlyy.entity.login.LoginLog;
 | 
												
													
														
															|  | 
 |  | //import com.yihu.wlyy.entity.patient.Patient;
 | 
												
													
														
															|  | 
 |  | //import com.yihu.wlyy.entity.security.Token;
 | 
												
													
														
															|  | 
 |  | //import com.yihu.wlyy.repository.security.TokenDao;
 | 
												
													
														
															|  | 
 |  | //import com.yihu.wlyy.service.common.SMSService;
 | 
												
													
														
															|  | 
 |  | //import com.yihu.wlyy.service.common.account.DoctorService;
 | 
												
													
														
															|  | 
 |  | //import com.yihu.wlyy.service.common.account.PatientService;
 | 
												
													
														
															|  | 
 |  | //import com.yihu.wlyy.service.common.account.RoleService;
 | 
												
													
														
															|  | 
 |  | //import com.yihu.wlyy.service.common.account.TokenService;
 | 
												
													
														
															|  | 
 |  | //import com.yihu.wlyy.service.common.login.LoginLogService;
 | 
												
													
														
															|  | 
 |  | //import com.yihu.wlyy.util.DateUtil;
 | 
												
													
														
															|  | 
 |  | //import com.yihu.wlyy.util.MD5;
 | 
												
													
														
															|  | 
 |  | //import com.yihu.wlyy.util.RSAUtils;
 | 
												
													
														
															|  | 
 |  | //import com.yihu.wlyy.util.SystemData;
 | 
												
													
														
															|  | 
 |  | //import com.yihu.wlyy.web.BaseController;
 | 
												
													
														
															|  | //import io.swagger.annotations.Api;
 |  | //import io.swagger.annotations.Api;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | /**
 |  | 
 | 
												
													
														
															|  |  * @author calvin
 |  | 
 | 
												
													
														
															|  |  */
 |  | 
 | 
												
													
														
															|  | @Controller
 |  | 
 | 
												
													
														
															|  | @RequestMapping(value = "/loginPC", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
 |  | 
 | 
												
													
														
															|  | @Api(description = "健康师登录取药系统")
 |  | 
 | 
												
													
														
															|  | public class PCLoginController extends BaseController {
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @Autowired
 |  | 
 | 
												
													
														
															|  |     private DoctorService doctorService;
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @Autowired
 |  | 
 | 
												
													
														
															|  |     private TokenService tokenService;
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @Autowired
 |  | 
 | 
												
													
														
															|  |     private SMSService smsService;
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @Autowired
 |  | 
 | 
												
													
														
															|  |     public TokenDao tokenDao;
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @Autowired
 |  | 
 | 
												
													
														
															|  |     private RoleService roleService;
 |  | 
 | 
												
													
														
															|  |     @Autowired
 |  | 
 | 
												
													
														
															|  |     private LoginLogService loginLogService;
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     /**
 |  | 
 | 
												
													
														
															|  |      *
 |  | 
 | 
												
													
														
															|  |      * @param mobile 手机号
 |  | 
 | 
												
													
														
															|  |      * @param captcha 短信验证码
 |  | 
 | 
												
													
														
															|  |      * @param platform  1、患者端,2、医生端app,3、微信公众号wechat,4、医生端pc,5PC端取药系统
 |  | 
 | 
												
													
														
															|  |      * @param password 密码
 |  | 
 | 
												
													
														
															|  |      * @return
 |  | 
 | 
												
													
														
															|  |      */
 |  | 
 | 
												
													
														
															|  |     @RequestMapping(value = "doctor",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
 |  | 
 | 
												
													
														
															|  |     @ResponseBody
 |  | 
 | 
												
													
														
															|  |     public String doctor(@ApiParam(required = false, name = "mobile", value = "手机号") @RequestParam(required = false,value = "mobile") String mobile,
 |  | 
 | 
												
													
														
															|  |                          @ApiParam(required = false, name = "captcha", value = "短信验证码") @RequestParam(required = false) String captcha,
 |  | 
 | 
												
													
														
															|  |                          @ApiParam(required = false, name = "platform", value = "医生端pc") @RequestParam(required = false,defaultValue = "5") Integer platform,
 |  | 
 | 
												
													
														
															|  |                          @ApiParam(required = false, name = "password", value = "密码") @RequestParam(required = false) String password) {
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         String errorMessage;
 |  | 
 | 
												
													
														
															|  |         LoginLog loginLog=new LoginLog();
 |  | 
 | 
												
													
														
															|  |         loginLog.setCreateTime(new Date());
 |  | 
 | 
												
													
														
															|  |         loginLog.setPhone(mobile);
 |  | 
 | 
												
													
														
															|  |         loginLog.setType("2");
 |  | 
 | 
												
													
														
															|  |         loginLog.setUserType("2");
 |  | 
 | 
												
													
														
															|  |         loginLog.setAppVersion(super.getAppVersion());
 |  | 
 | 
												
													
														
															|  |         try {
 |  | 
 | 
												
													
														
															|  |             if(platform==null){
 |  | 
 | 
												
													
														
															|  |                 platform = 5;//默认为医生app端
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  |             //身份证登录
 |  | 
 | 
												
													
														
															|  |             if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(password)){
 |  | 
 | 
												
													
														
															|  |                 password = RSAUtils.getInstance(doctorService).decryptString(password);
 |  | 
 | 
												
													
														
															|  |                 password=StringUtils.reverse(password);
 |  | 
 | 
												
													
														
															|  |                 Doctor doctor=doctorService.findDoctorByMobile(mobile);
 |  | 
 | 
												
													
														
															|  |                 loginLog.setLoginType("2");
 |  | 
 | 
												
													
														
															|  |                 if(doctor==null){
 |  | 
 | 
												
													
														
															|  |                     errorMessage="该号码未注册!";
 |  | 
 | 
												
													
														
															|  |                     loginLog.setErrorMessage(errorMessage);
 |  | 
 | 
												
													
														
															|  |                     loginLogService.saveLog(loginLog);
 |  | 
 | 
												
													
														
															|  |                     return error(-1,errorMessage);
 |  | 
 | 
												
													
														
															|  |                 }
 |  | 
 | 
												
													
														
															|  |                 loginLog.setUserCode(doctor.getCode());
 |  | 
 | 
												
													
														
															|  |                 String loginPassword= MD5.GetMD5Code(password+doctor.getSalt());
 |  | 
 | 
												
													
														
															|  |                 if(loginPassword.equals(doctor.getPassword())){
 |  | 
 | 
												
													
														
															|  |                     //使用i健康系统账号体系,只有健康师有权限登录取药系统
 |  | 
 | 
												
													
														
															|  |                     if(doctor.getLevel()!=3){
 |  | 
 | 
												
													
														
															|  |                         loginLog.setType("2");
 |  | 
 | 
												
													
														
															|  |                         errorMessage="该用户角色没有登录权限!";
 |  | 
 | 
												
													
														
															|  |                         loginLog.setErrorMessage(errorMessage);
 |  | 
 | 
												
													
														
															|  |                         loginLogService.saveLog(loginLog);
 |  | 
 | 
												
													
														
															|  |                         return error(-1, errorMessage);
 |  | 
 | 
												
													
														
															|  |                     }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |                     // 用户校验通过,生成token
 |  | 
 | 
												
													
														
															|  |                     Token token = tokenService.newToken(doctor.getCode(), "pc", platform);
 |  | 
 | 
												
													
														
															|  |                     loginLog.setTokenId(token.getId());
 |  | 
 | 
												
													
														
															|  |                     loginLog.setType("1");
 |  | 
 | 
												
													
														
															|  |                     Map<String, Object> map = new HashMap<>();
 |  | 
 | 
												
													
														
															|  |                     map.put("id", doctor.getId());
 |  | 
 | 
												
													
														
															|  |                     map.put("uid", doctor.getCode());
 |  | 
 | 
												
													
														
															|  |                     map.put("token", token.getToken());
 |  | 
 | 
												
													
														
															|  |                     map.put("name", doctor.getName());
 |  | 
 | 
												
													
														
															|  |                     map.put("hospital", doctor.getHospital());
 |  | 
 | 
												
													
														
															|  |                     map.put("photo", doctor.getPhoto());
 |  | 
 | 
												
													
														
															|  |                     // 设置医生类型:1专科医生,2全科医生,3健康管理师
 |  | 
 | 
												
													
														
															|  |                     map.put("doctorType", doctor.getLevel());
 |  | 
 | 
												
													
														
															|  |                     //获取医生角色和区域权限
 |  | 
 | 
												
													
														
															|  | //                    List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(doctor.getCode());
 |  | 
 | 
												
													
														
															|  | //                    map.put("userRole", roleMap);
 |  | 
 | 
												
													
														
															|  | //                    if("10".equals(doctor.getLevel())&&roleMap.size()==0){
 |  | 
 | 
												
													
														
															|  | //                        errorMessage="该用户没有管理员权限";
 |  | 
 | 
												
													
														
															|  | 
 |  | //import io.swagger.annotations.ApiParam;
 | 
												
													
														
															|  | 
 |  | //import org.apache.commons.lang3.StringUtils;
 | 
												
													
														
															|  | 
 |  | //import org.json.JSONObject;
 | 
												
													
														
															|  | 
 |  | //import org.patchca.color.SingleColorFactory;
 | 
												
													
														
															|  | 
 |  | //import org.patchca.filter.predefined.*;
 | 
												
													
														
															|  | 
 |  | //import org.patchca.service.ConfigurableCaptchaService;
 | 
												
													
														
															|  | 
 |  | //import org.patchca.utils.encoder.EncoderHelper;
 | 
												
													
														
															|  | 
 |  | //import org.springframework.beans.factory.annotation.Autowired;
 | 
												
													
														
															|  | 
 |  | //import org.springframework.http.MediaType;
 | 
												
													
														
															|  | 
 |  | //import org.springframework.stereotype.Controller;
 | 
												
													
														
															|  | 
 |  | //import org.springframework.web.bind.annotation.RequestMapping;
 | 
												
													
														
															|  | 
 |  | //import org.springframework.web.bind.annotation.RequestMethod;
 | 
												
													
														
															|  | 
 |  | //import org.springframework.web.bind.annotation.RequestParam;
 | 
												
													
														
															|  | 
 |  | //import org.springframework.web.bind.annotation.ResponseBody;
 | 
												
													
														
															|  | 
 |  | //
 | 
												
													
														
															|  | 
 |  | //import javax.servlet.http.HttpServletRequest;
 | 
												
													
														
															|  | 
 |  | //import javax.servlet.http.HttpServletResponse;
 | 
												
													
														
															|  | 
 |  | //import javax.servlet.http.HttpSession;
 | 
												
													
														
															|  | 
 |  | //import java.awt.*;
 | 
												
													
														
															|  | 
 |  | //import java.io.IOException;
 | 
												
													
														
															|  | 
 |  | //import java.util.*;
 | 
												
													
														
															|  | 
 |  | //import java.util.List;
 | 
												
													
														
															|  | 
 |  | //
 | 
												
													
														
															|  | 
 |  | ////import io.swagger.annotations.Api;
 | 
												
													
														
															|  | 
 |  | //
 | 
												
													
														
															|  | 
 |  | ///**
 | 
												
													
														
															|  | 
 |  | // * @author calvin
 | 
												
													
														
															|  | 
 |  | // */
 | 
												
													
														
															|  | 
 |  | //@Controller
 | 
												
													
														
															|  | 
 |  | //@RequestMapping(value = "/loginPC", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
 | 
												
													
														
															|  | 
 |  | //@Api(description = "健康师登录取药系统")
 | 
												
													
														
															|  | 
 |  | //public class PCLoginController extends BaseController {
 | 
												
													
														
															|  | 
 |  | //
 | 
												
													
														
															|  | 
 |  | //    @Autowired
 | 
												
													
														
															|  | 
 |  | //    private DoctorService doctorService;
 | 
												
													
														
															|  | 
 |  | //
 | 
												
													
														
															|  | 
 |  | //    @Autowired
 | 
												
													
														
															|  | 
 |  | //    private TokenService tokenService;
 | 
												
													
														
															|  | 
 |  | //
 | 
												
													
														
															|  | 
 |  | //    @Autowired
 | 
												
													
														
															|  | 
 |  | //    private SMSService smsService;
 | 
												
													
														
															|  | 
 |  | //
 | 
												
													
														
															|  | 
 |  | //    @Autowired
 | 
												
													
														
															|  | 
 |  | //    public TokenDao tokenDao;
 | 
												
													
														
															|  | 
 |  | //
 | 
												
													
														
															|  | 
 |  | //    @Autowired
 | 
												
													
														
															|  | 
 |  | //    private RoleService roleService;
 | 
												
													
														
															|  | 
 |  | //    @Autowired
 | 
												
													
														
															|  | 
 |  | //    private LoginLogService loginLogService;
 | 
												
													
														
															|  | 
 |  | //
 | 
												
													
														
															|  | 
 |  | //    /**
 | 
												
													
														
															|  | 
 |  | //     *
 | 
												
													
														
															|  | 
 |  | //     * @param mobile 手机号
 | 
												
													
														
															|  | 
 |  | //     * @param captcha 短信验证码
 | 
												
													
														
															|  | 
 |  | //     * @param platform  1、患者端,2、医生端app,3、微信公众号wechat,4、医生端pc,5PC端取药系统
 | 
												
													
														
															|  | 
 |  | //     * @param password 密码
 | 
												
													
														
															|  | 
 |  | //     * @return
 | 
												
													
														
															|  | 
 |  | //     */
 | 
												
													
														
															|  | 
 |  | //    @RequestMapping(value = "doctor",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
 | 
												
													
														
															|  | 
 |  | //    @ResponseBody
 | 
												
													
														
															|  | 
 |  | //    public String doctor(@ApiParam(required = false, name = "mobile", value = "手机号") @RequestParam(required = false,value = "mobile") String mobile,
 | 
												
													
														
															|  | 
 |  | //                         @ApiParam(required = false, name = "captcha", value = "短信验证码") @RequestParam(required = false) String captcha,
 | 
												
													
														
															|  | 
 |  | //                         @ApiParam(required = false, name = "platform", value = "医生端pc") @RequestParam(required = false,defaultValue = "4") Integer platform,
 | 
												
													
														
															|  | 
 |  | //                         @ApiParam(required = false, name = "password", value = "密码") @RequestParam(required = false) String password) {
 | 
												
													
														
															|  | 
 |  | //
 | 
												
													
														
															|  | 
 |  | //        String errorMessage;
 | 
												
													
														
															|  | 
 |  | //        LoginLog loginLog=new LoginLog();
 | 
												
													
														
															|  | 
 |  | //        loginLog.setCreateTime(new Date());
 | 
												
													
														
															|  | 
 |  | //        loginLog.setPhone(mobile);
 | 
												
													
														
															|  | 
 |  | //        loginLog.setType("2");
 | 
												
													
														
															|  | 
 |  | //        loginLog.setUserType("2");
 | 
												
													
														
															|  | 
 |  | //        loginLog.setAppVersion(super.getAppVersion());
 | 
												
													
														
															|  | 
 |  | //        try {
 | 
												
													
														
															|  | 
 |  | //            if(platform==null){
 | 
												
													
														
															|  | 
 |  | //                platform = 4;//默认为医生app端
 | 
												
													
														
															|  | 
 |  | //            }
 | 
												
													
														
															|  | 
 |  | //            //身份证登录
 | 
												
													
														
															|  | 
 |  | //            if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(password)){
 | 
												
													
														
															|  | 
 |  | //                password = RSAUtils.getInstance(doctorService).decryptString(password);
 | 
												
													
														
															|  | 
 |  | //                password=StringUtils.reverse(password);
 | 
												
													
														
															|  | 
 |  | //                Doctor doctor=doctorService.findDoctorByMobile(mobile);
 | 
												
													
														
															|  | 
 |  | //                loginLog.setLoginType("2");
 | 
												
													
														
															|  | 
 |  | //                if(doctor==null){
 | 
												
													
														
															|  | 
 |  | //                    errorMessage="该号码未注册!";
 | 
												
													
														
															|  | 
 |  | //                    loginLog.setErrorMessage(errorMessage);
 | 
												
													
														
															|  | 
 |  | //                    loginLogService.saveLog(loginLog);
 | 
												
													
														
															|  | 
 |  | //                    return error(-1,errorMessage);
 | 
												
													
														
															|  | 
 |  | //                }
 | 
												
													
														
															|  | 
 |  | //                loginLog.setUserCode(doctor.getCode());
 | 
												
													
														
															|  | 
 |  | //                String loginPassword= MD5.GetMD5Code(password+doctor.getSalt());
 | 
												
													
														
															|  | 
 |  | //                if(loginPassword.equals(doctor.getPassword())){
 | 
												
													
														
															|  | 
 |  | //                    //使用i健康系统账号体系,只有健康师有权限登录取药系统
 | 
												
													
														
															|  | 
 |  | //                    if(doctor.getLevel()!=3){
 | 
												
													
														
															|  | 
 |  | //                        loginLog.setType("2");
 | 
												
													
														
															|  | 
 |  | //                        errorMessage="该用户角色没有登录权限!";
 | 
												
													
														
															|  | //                        loginLog.setErrorMessage(errorMessage);
 |  | //                        loginLog.setErrorMessage(errorMessage);
 | 
												
													
														
															|  | //                        loginLogService.saveLog(loginLog);
 |  | //                        loginLogService.saveLog(loginLog);
 | 
												
													
														
															|  | //                        return error(-1, errorMessage);
 |  | //                        return error(-1, errorMessage);
 | 
												
													
														
															|  | //                    }
 |  | //                    }
 | 
												
													
														
															|  |                     loginLogService.saveLog(loginLog);
 |  | 
 | 
												
													
														
															|  |                     return write(200, "登录成功", "data", map);
 |  | 
 | 
												
													
														
															|  |                 }else{
 |  | 
 | 
												
													
														
															|  |                     errorMessage="密码错误,登录失败";
 |  | 
 | 
												
													
														
															|  |                     loginLog.setErrorMessage(errorMessage);
 |  | 
 | 
												
													
														
															|  |                     loginLogService.saveLog(loginLog);
 |  | 
 | 
												
													
														
															|  |                     return error(-1, errorMessage);
 |  | 
 | 
												
													
														
															|  |                 }
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  |             if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(captcha)){
 |  | 
 | 
												
													
														
															|  |                 // 对验证码进行校验
 |  | 
 | 
												
													
														
															|  |                 int res = smsService.check(mobile, 5, captcha);
 |  | 
 | 
												
													
														
															|  |                 switch (res) {
 |  | 
 | 
												
													
														
															|  |                     case -2:{
 |  | 
 | 
												
													
														
															|  |                         errorMessage="验证码已过期!";
 |  | 
 | 
												
													
														
															|  |                         loginLog.setErrorMessage(errorMessage);
 |  | 
 | 
												
													
														
															|  |                         loginLogService.saveLog(loginLog);
 |  | 
 | 
												
													
														
															|  |                         return error(-1, errorMessage);}
 |  | 
 | 
												
													
														
															|  |                     case -1:{
 |  | 
 | 
												
													
														
															|  |                         errorMessage="请输入正确的验证码!";
 |  | 
 | 
												
													
														
															|  |                         loginLog.setErrorMessage(errorMessage);
 |  | 
 | 
												
													
														
															|  |                         loginLogService.saveLog(loginLog);
 |  | 
 | 
												
													
														
															|  |                         return error(-1, errorMessage);}
 |  | 
 | 
												
													
														
															|  |                     case 0:{
 |  | 
 | 
												
													
														
															|  |                         errorMessage="验证码无效!";
 |  | 
 | 
												
													
														
															|  |                         loginLog.setErrorMessage(errorMessage);
 |  | 
 | 
												
													
														
															|  |                         loginLogService.saveLog(loginLog);
 |  | 
 | 
												
													
														
															|  |                         return error(-1, errorMessage);}
 |  | 
 | 
												
													
														
															|  |                 }
 |  | 
 | 
												
													
														
															|  |                 Doctor doctor = doctorService.findDoctorByMobile(mobile);
 |  | 
 | 
												
													
														
															|  |                 loginLog.setLoginType("1");
 |  | 
 | 
												
													
														
															|  |                 if (doctor == null) {
 |  | 
 | 
												
													
														
															|  |                     errorMessage="该手机号未注册,请确认!";
 |  | 
 | 
												
													
														
															|  |                     loginLog.setErrorMessage(errorMessage);
 |  | 
 | 
												
													
														
															|  |                     loginLogService.saveLog(loginLog);
 |  | 
 | 
												
													
														
															|  |                     return error(-1, errorMessage);
 |  | 
 | 
												
													
														
															|  |                 } else {
 |  | 
 | 
												
													
														
															|  |                     loginLog.setUserCode(doctor.getCode());
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |                     //使用i健康系统账号体系,只有健康师有权限登录取药系统
 |  | 
 | 
												
													
														
															|  |                     if(doctor.getLevel()!=3){
 |  | 
 | 
												
													
														
															|  |                         loginLog.setType("2");
 |  | 
 | 
												
													
														
															|  |                         errorMessage="该用户角色没有登录权限!";
 |  | 
 | 
												
													
														
															|  |                         loginLog.setErrorMessage(errorMessage);
 |  | 
 | 
												
													
														
															|  |                         loginLogService.saveLog(loginLog);
 |  | 
 | 
												
													
														
															|  |                         return error(-1, errorMessage);
 |  | 
 | 
												
													
														
															|  |                     }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |                     // 用户校验通过,生成token
 |  | 
 | 
												
													
														
															|  |                     Token token = tokenService.newToken(doctor.getCode(), "pc", platform);
 |  | 
 | 
												
													
														
															|  |                     loginLog.setTokenId(token.getId());
 |  | 
 | 
												
													
														
															|  |                     loginLog.setType("1");
 |  | 
 | 
												
													
														
															|  |                     Map<String, Object> map = new HashMap<>();
 |  | 
 | 
												
													
														
															|  |                     map.put("id", doctor.getId());
 |  | 
 | 
												
													
														
															|  |                     map.put("uid", doctor.getCode());
 |  | 
 | 
												
													
														
															|  |                     map.put("token", token.getToken());
 |  | 
 | 
												
													
														
															|  |                     map.put("name", doctor.getName());
 |  | 
 | 
												
													
														
															|  |                     map.put("hospital", doctor.getHospital());
 |  | 
 | 
												
													
														
															|  |                     map.put("photo", doctor.getPhoto());
 |  | 
 | 
												
													
														
															|  |                     // 设置医生类型:1专科医生,2全科医生,3健康管理师
 |  | 
 | 
												
													
														
															|  |                     map.put("doctorType", doctor.getLevel());
 |  | 
 | 
												
													
														
															|  |                     //获取医生角色和区域权限
 |  | 
 | 
												
													
														
															|  | //                    List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(doctor.getCode());
 |  | 
 | 
												
													
														
															|  | //                    map.put("userRole", roleMap);
 |  | 
 | 
												
													
														
															|  | //                    if("10".equals(doctor.getLevel())&&roleMap.size()==0){
 |  | 
 | 
												
													
														
															|  | //                        errorMessage="改用户没有管理员权限";
 |  | 
 | 
												
													
														
															|  | 
 |  | //
 | 
												
													
														
															|  | 
 |  | //
 | 
												
													
														
															|  | 
 |  | //                    // 用户校验通过,生成token
 | 
												
													
														
															|  | 
 |  | //                    Token token = tokenService.newToken(doctor.getCode(), "pc", platform);
 | 
												
													
														
															|  | 
 |  | //                    loginLog.setTokenId(token.getId());
 | 
												
													
														
															|  | 
 |  | //                    loginLog.setType("1");
 | 
												
													
														
															|  | 
 |  | //                    Map<String, Object> map = new HashMap<>();
 | 
												
													
														
															|  | 
 |  | //                    map.put("id", doctor.getId());
 | 
												
													
														
															|  | 
 |  | //                    map.put("uid", doctor.getCode());
 | 
												
													
														
															|  | 
 |  | //                    map.put("token", token.getToken());
 | 
												
													
														
															|  | 
 |  | //                    map.put("name", doctor.getName());
 | 
												
													
														
															|  | 
 |  | //                    map.put("hospital", doctor.getHospital());
 | 
												
													
														
															|  | 
 |  | //                    map.put("photo", doctor.getPhoto());
 | 
												
													
														
															|  | 
 |  | //                    // 设置医生类型:1专科医生,2全科医生,3健康管理师
 | 
												
													
														
															|  | 
 |  | //                    map.put("doctorType", doctor.getLevel());
 | 
												
													
														
															|  | 
 |  | //                    //获取医生角色和区域权限
 | 
												
													
														
															|  | 
 |  | ////                    List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(doctor.getCode());
 | 
												
													
														
															|  | 
 |  | ////                    map.put("userRole", roleMap);
 | 
												
													
														
															|  | 
 |  | ////                    if("10".equals(doctor.getLevel())&&roleMap.size()==0){
 | 
												
													
														
															|  | 
 |  | ////                        errorMessage="该用户没有管理员权限";
 | 
												
													
														
															|  | 
 |  | ////                        loginLog.setErrorMessage(errorMessage);
 | 
												
													
														
															|  | 
 |  | ////                        loginLogService.saveLog(loginLog);
 | 
												
													
														
															|  | 
 |  | ////                        return error(-1, errorMessage);
 | 
												
													
														
															|  | 
 |  | ////                    }
 | 
												
													
														
															|  | 
 |  | //                    loginLogService.saveLog(loginLog);
 | 
												
													
														
															|  | 
 |  | //                    return write(200, "登录成功", "data", map);
 | 
												
													
														
															|  | 
 |  | //                }else{
 | 
												
													
														
															|  | 
 |  | //                    errorMessage="密码错误,登录失败";
 | 
												
													
														
															|  | 
 |  | //                    loginLog.setErrorMessage(errorMessage);
 | 
												
													
														
															|  | 
 |  | //                    loginLogService.saveLog(loginLog);
 | 
												
													
														
															|  | 
 |  | //                    return error(-1, errorMessage);
 | 
												
													
														
															|  | 
 |  | //                }
 | 
												
													
														
															|  | 
 |  | //            }
 | 
												
													
														
															|  | 
 |  | //            if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(captcha)){
 | 
												
													
														
															|  | 
 |  | //                // 对验证码进行校验
 | 
												
													
														
															|  | 
 |  | //                int res = smsService.check(mobile, 5, captcha);
 | 
												
													
														
															|  | 
 |  | //                switch (res) {
 | 
												
													
														
															|  | 
 |  | //                    case -2:{
 | 
												
													
														
															|  | 
 |  | //                        errorMessage="验证码已过期!";
 | 
												
													
														
															|  | 
 |  | //                        loginLog.setErrorMessage(errorMessage);
 | 
												
													
														
															|  | 
 |  | //                        loginLogService.saveLog(loginLog);
 | 
												
													
														
															|  | 
 |  | //                        return error(-1, errorMessage);}
 | 
												
													
														
															|  | 
 |  | //                    case -1:{
 | 
												
													
														
															|  | 
 |  | //                        errorMessage="请输入正确的验证码!";
 | 
												
													
														
															|  | 
 |  | //                        loginLog.setErrorMessage(errorMessage);
 | 
												
													
														
															|  | 
 |  | //                        loginLogService.saveLog(loginLog);
 | 
												
													
														
															|  | 
 |  | //                        return error(-1, errorMessage);}
 | 
												
													
														
															|  | 
 |  | //                    case 0:{
 | 
												
													
														
															|  | 
 |  | //                        errorMessage="验证码无效!";
 | 
												
													
														
															|  | 
 |  | //                        loginLog.setErrorMessage(errorMessage);
 | 
												
													
														
															|  | 
 |  | //                        loginLogService.saveLog(loginLog);
 | 
												
													
														
															|  | 
 |  | //                        return error(-1, errorMessage);}
 | 
												
													
														
															|  | 
 |  | //                }
 | 
												
													
														
															|  | 
 |  | //                Doctor doctor = doctorService.findDoctorByMobile(mobile);
 | 
												
													
														
															|  | 
 |  | //                loginLog.setLoginType("1");
 | 
												
													
														
															|  | 
 |  | //                if (doctor == null) {
 | 
												
													
														
															|  | 
 |  | //                    errorMessage="该手机号未注册,请确认!";
 | 
												
													
														
															|  | 
 |  | //                    loginLog.setErrorMessage(errorMessage);
 | 
												
													
														
															|  | 
 |  | //                    loginLogService.saveLog(loginLog);
 | 
												
													
														
															|  | 
 |  | //                    return error(-1, errorMessage);
 | 
												
													
														
															|  | 
 |  | //                } else {
 | 
												
													
														
															|  | 
 |  | //                    loginLog.setUserCode(doctor.getCode());
 | 
												
													
														
															|  | 
 |  | //
 | 
												
													
														
															|  | 
 |  | //                    //使用i健康系统账号体系,只有健康师有权限登录取药系统
 | 
												
													
														
															|  | 
 |  | //                    if(doctor.getLevel()!=3){
 | 
												
													
														
															|  | 
 |  | //                        loginLog.setType("2");
 | 
												
													
														
															|  | 
 |  | //                        errorMessage="该用户角色没有登录权限!";
 | 
												
													
														
															|  | //                        loginLog.setErrorMessage(errorMessage);
 |  | //                        loginLog.setErrorMessage(errorMessage);
 | 
												
													
														
															|  | //                        loginLogService.saveLog(loginLog);
 |  | //                        loginLogService.saveLog(loginLog);
 | 
												
													
														
															|  | //                        return error(-1, errorMessage);
 |  | //                        return error(-1, errorMessage);
 | 
												
													
														
															|  | //                    }
 |  | //                    }
 | 
												
													
														
															|  |                     loginLogService.saveLog(loginLog);
 |  | 
 | 
												
													
														
															|  |                     return write(200, "登录成功", "data", map);
 |  | 
 | 
												
													
														
															|  |                 }
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  |             errorMessage="登录信息不完整,请重新输入!";
 |  | 
 | 
												
													
														
															|  |             loginLog.setErrorMessage(errorMessage);
 |  | 
 | 
												
													
														
															|  |             loginLogService.saveLog(loginLog);
 |  | 
 | 
												
													
														
															|  |             return error(-1,errorMessage);
 |  | 
 | 
												
													
														
															|  |         } catch (Exception e) {
 |  | 
 | 
												
													
														
															|  |             loginLog.setErrorMessage(e.getMessage());
 |  | 
 | 
												
													
														
															|  |             loginLogService.saveLog(loginLog);
 |  | 
 | 
												
													
														
															|  |             error(e);
 |  | 
 | 
												
													
														
															|  |             return error(-1, "系统异常,登录失败");
 |  | 
 | 
												
													
														
															|  |         }
 |  | 
 | 
												
													
														
															|  |     }
 |  | 
 | 
												
													
														
															|  | }
 |  | 
 | 
												
													
														
															|  | 
 |  | //
 | 
												
													
														
															|  | 
 |  | //                    // 用户校验通过,生成token
 | 
												
													
														
															|  | 
 |  | //                    Token token = tokenService.newToken(doctor.getCode(), "pc", platform);
 | 
												
													
														
															|  | 
 |  | //                    loginLog.setTokenId(token.getId());
 | 
												
													
														
															|  | 
 |  | //                    loginLog.setType("1");
 | 
												
													
														
															|  | 
 |  | //                    Map<String, Object> map = new HashMap<>();
 | 
												
													
														
															|  | 
 |  | //                    map.put("id", doctor.getId());
 | 
												
													
														
															|  | 
 |  | //                    map.put("uid", doctor.getCode());
 | 
												
													
														
															|  | 
 |  | //                    map.put("token", token.getToken());
 | 
												
													
														
															|  | 
 |  | //                    map.put("name", doctor.getName());
 | 
												
													
														
															|  | 
 |  | //                    map.put("hospital", doctor.getHospital());
 | 
												
													
														
															|  | 
 |  | //                    map.put("photo", doctor.getPhoto());
 | 
												
													
														
															|  | 
 |  | //                    // 设置医生类型:1专科医生,2全科医生,3健康管理师
 | 
												
													
														
															|  | 
 |  | //                    map.put("doctorType", doctor.getLevel());
 | 
												
													
														
															|  | 
 |  | //                    //获取医生角色和区域权限
 | 
												
													
														
															|  | 
 |  | ////                    List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(doctor.getCode());
 | 
												
													
														
															|  | 
 |  | ////                    map.put("userRole", roleMap);
 | 
												
													
														
															|  | 
 |  | ////                    if("10".equals(doctor.getLevel())&&roleMap.size()==0){
 | 
												
													
														
															|  | 
 |  | ////                        errorMessage="改用户没有管理员权限";
 | 
												
													
														
															|  | 
 |  | ////                        loginLog.setErrorMessage(errorMessage);
 | 
												
													
														
															|  | 
 |  | ////                        loginLogService.saveLog(loginLog);
 | 
												
													
														
															|  | 
 |  | ////                        return error(-1, errorMessage);
 | 
												
													
														
															|  | 
 |  | ////                    }
 | 
												
													
														
															|  | 
 |  | //                    loginLogService.saveLog(loginLog);
 | 
												
													
														
															|  | 
 |  | //                    return write(200, "登录成功", "data", map);
 | 
												
													
														
															|  | 
 |  | //                }
 | 
												
													
														
															|  | 
 |  | //            }
 | 
												
													
														
															|  | 
 |  | //            errorMessage="登录信息不完整,请重新输入!";
 | 
												
													
														
															|  | 
 |  | //            loginLog.setErrorMessage(errorMessage);
 | 
												
													
														
															|  | 
 |  | //            loginLogService.saveLog(loginLog);
 | 
												
													
														
															|  | 
 |  | //            return error(-1,errorMessage);
 | 
												
													
														
															|  | 
 |  | //        } catch (Exception e) {
 | 
												
													
														
															|  | 
 |  | //            loginLog.setErrorMessage(e.getMessage());
 | 
												
													
														
															|  | 
 |  | //            loginLogService.saveLog(loginLog);
 | 
												
													
														
															|  | 
 |  | //            error(e);
 | 
												
													
														
															|  | 
 |  | //            return error(-1, "系统异常,登录失败");
 | 
												
													
														
															|  | 
 |  | //        }
 | 
												
													
														
															|  | 
 |  | //    }
 | 
												
													
														
															|  | 
 |  | //}
 |