|
|
|
@@ -35,6 +35,7 @@ import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.validation.Valid; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
/** |
|
|
|
@@ -66,14 +67,15 @@ public class TokenController { |
|
|
|
@Autowired |
|
|
|
private RedisService redisService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RemoteTenantService tenantService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RedisTemplate<String, String> redisTemplate; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RemoteTenantService tenantService; |
|
|
|
|
|
|
|
|
|
|
|
private final static String REDIS_LOGIN_CODE_PIX = "saas:login:code:"; |
|
|
|
private static final String REDIS_LOGIN_CODE_PIX = "saas:login:code:"; |
|
|
|
|
|
|
|
@PostMapping("login") |
|
|
|
public AjaxResult login(@RequestBody LoginBody form) { |
|
|
|
@@ -85,21 +87,20 @@ public class TokenController { |
|
|
|
|
|
|
|
@PostMapping("phoneLogin") |
|
|
|
public AjaxResult loginByPhone(@Valid @RequestBody PhoneLoginBody form) { |
|
|
|
/*if (!RedisUtil.existed(REDIS_LOGIN_CODE_PIX + form.getPhone())) { |
|
|
|
return AjaxResult.error("手机号输入错误或验证码已过期"); |
|
|
|
} else { |
|
|
|
Integer code = (Integer) RedisUtil.getVal(REDIS_LOGIN_CODE_PIX + form.getPhone()); |
|
|
|
if (null != code && !form.getCode().equals(code.toString())) { |
|
|
|
return AjaxResult.error("验证码输入不正确"); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
R<SysEnterpriseStaff> staffR = tenantService.queryStaff(form.getPhone(), SecurityConstants.INNER); |
|
|
|
if (staffR.isFail() || staffR.getData() == null) { |
|
|
|
return AjaxResult.error("手机号不正确,清查验"); |
|
|
|
} |
|
|
|
|
|
|
|
// 用户手机号验证登录 |
|
|
|
LoginUser userInfo = sysLoginService.loginByPhone(form.getPhone()); |
|
|
|
if (null == userInfo) { |
|
|
|
return AjaxResult.error("手机号不正确,清查验"); |
|
|
|
} |
|
|
|
// 获取登录token |
|
|
|
return AjaxResult.success(tokenService.createToken(userInfo)); |
|
|
|
Map<String, Object> map = tokenService.createToken(userInfo); |
|
|
|
map.put("staffId", staffR.getData().getId());//塞入对应staffId |
|
|
|
return AjaxResult.success(map); |
|
|
|
} |
|
|
|
|
|
|
|
@DeleteMapping("logout") |
|
|
|
|