提交医生详情信息
parent
1e3343188f
commit
6e2167a7f0
|
@ -4,7 +4,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||
|
||||
import com.four.auth.service.SysMailService;
|
||||
import com.four.common.duck.request.RequestRegistrationInformation;
|
||||
import com.four.system.api.domain.SysUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.four.auth.form.LoginBody;
|
||||
|
@ -35,6 +34,11 @@ public class TokenController {
|
|||
@Autowired
|
||||
private SysMailService sysMailService;
|
||||
|
||||
/***
|
||||
* 邮箱密码登录
|
||||
* @param form
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("login")
|
||||
public R<?> login(@RequestBody LoginBody form) {
|
||||
// 用户登录
|
||||
|
@ -43,6 +47,24 @@ public class TokenController {
|
|||
return R.ok(tokenService.createToken(userInfo));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 人脸邮箱登录
|
||||
* @param form
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("emailLogin")
|
||||
public R<?> emailLogin(@RequestBody LoginBody form){
|
||||
|
||||
LoginUser loginUser = sysLoginService.emailLogin(form.getEmail());
|
||||
|
||||
return R.ok(tokenService.createToken(loginUser));
|
||||
}
|
||||
/**4
|
||||
* 用户名密码登录
|
||||
* @param form
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("userLogin")
|
||||
public R<?> userLogin(@RequestBody LoginBody form) {
|
||||
|
||||
|
@ -51,6 +73,11 @@ public class TokenController {
|
|||
return R.ok(tokenService.createToken(loginUser));
|
||||
}
|
||||
|
||||
/***
|
||||
* 登出
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("logout")
|
||||
public R<?> logout(HttpServletRequest request) {
|
||||
String token = SecurityUtils.getToken(request);
|
||||
|
|
|
@ -148,6 +148,12 @@ public class SysLoginService
|
|||
}
|
||||
|
||||
|
||||
/***
|
||||
* 用户名 密码登录
|
||||
* @param userName
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
|
||||
public LoginUser userLogin(String userName, String password) {
|
||||
|
||||
|
@ -283,4 +289,48 @@ public class SysLoginService
|
|||
recordLogService.recordLogininfor(registerBody.getEmail(),Constants.REGISTER,"注册成功");
|
||||
}
|
||||
|
||||
/***
|
||||
* 人脸邮箱后台登录
|
||||
* @param email
|
||||
* @return
|
||||
*/
|
||||
public LoginUser emailLogin(String email) {
|
||||
if(StringUtils.isAllBlank(email)){
|
||||
recordLogService.recordEmailLoginFors(email,Constants.LOGIN_FAIL,"邮箱必须填写");
|
||||
throw new ServiceException("邮箱必须填写");
|
||||
}
|
||||
|
||||
if(email.length() < UserConstants.USERNAME_MIN_LENGTH || email.length() > UserConstants.USERNAME_MAX_LENGTH){
|
||||
recordLogService.recordEmailLoginFors(email,Constants.LOGIN_FAIL,"用户不在指定范围内");
|
||||
throw new ServiceException("用户不在指定范围");
|
||||
|
||||
}
|
||||
|
||||
String blackStr = Convert.toStr(redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST));
|
||||
if(IpUtils.isMatchedIp(blackStr,IpUtils.getIpAddr())){
|
||||
recordLogService.recordEmailLoginFors(blackStr,Constants.LOGIN_FAIL,"很遗憾,访问IP已被列入系统黑名单");
|
||||
throw new ServiceException("很遗憾,访问IP已被列入系统黑名单");
|
||||
}
|
||||
|
||||
R<LoginUser> userResult = remoteUserService.getUserInfo(email, SecurityConstants.INNER);
|
||||
if(StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())){
|
||||
recordLogService.recordEmailLoginFors(email ,Constants.LOGIN_FAIL,"登录用户不存在");
|
||||
throw new ServiceException("登录用户:" + email + "不存在");
|
||||
}
|
||||
if(R.FAIL == userResult.getCode()){
|
||||
throw new ServiceException(userResult.getMsg());
|
||||
}
|
||||
|
||||
LoginUser dataInfo = userResult.getData();
|
||||
SysUser sysUser = userResult.getData().getSysUser();
|
||||
if(UserStatus.DISABLE.getCode().equals(sysUser.getDelFlag())){
|
||||
recordLogService.recordEmailLoginFors(email,Constants.LOGIN_FAIL,"对不起,您的账号已被删除");
|
||||
throw new ServiceException("对不起,你的账号" + email + "已被删除");
|
||||
}
|
||||
if(UserStatus.DISABLE.getCode().equals(sysUser.getStatus())){
|
||||
recordLogService.recordEmailLoginFors(email,Constants.LOGIN_FAIL,"用户已停用,");
|
||||
}
|
||||
recordLogService.recordEmailLoginFors(email,Constants.LOGIN_SUCCESS,"登录成功");
|
||||
return dataInfo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,8 @@ SysPasswordService
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
if (!matches(user, password))
|
||||
{
|
||||
retryCount = retryCount + 1;
|
||||
|
|
|
@ -58,4 +58,17 @@ public class SysRecordLogService
|
|||
remoteLogService.saveLogininfor(logininfor, SecurityConstants.INNER);
|
||||
}
|
||||
|
||||
public void recordEmailLoginFors(String email,String status,String message){
|
||||
SysLogininfor logininfor = new SysLogininfor();
|
||||
logininfor.setUserName(email);
|
||||
logininfor.setIpaddr(IpUtils.getIpAddr());
|
||||
logininfor.setMsg(message);
|
||||
if(StringUtils.equalsAny(status,Constants.LOGIN_SUCCESS , Constants.LOGOUT,Constants.REGISTER)){
|
||||
logininfor.setStatus(Constants.LOGIN_SUCCESS_STATUS);
|
||||
}else if (Constants.LOGIN_FAIL.equals(status)){
|
||||
logininfor.setStatus(Constants.LOGIN_SUCCESS_STATUS);
|
||||
}
|
||||
remoteLogService.saveLogininfor(logininfor,SecurityConstants.INNER);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 101.34.252.165:8848
|
||||
namespace: xiaoxu
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 101.34.252.165:8848
|
||||
namespace: xiaoxu
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
Loading…
Reference in New Issue