|
@@ -9,6 +9,7 @@ import com.ruoyi.system.service.IDataSourceService;
|
|
|
import com.ruoyi.system.service.impl.SysTenantServiceImpl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -25,6 +26,7 @@ import com.ruoyi.system.service.ISysMenuService;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.validation.Valid;
|
|
|
|
|
|
/**
|
|
|
* 登录验证
|
|
@@ -76,13 +78,16 @@ public class SysLoginController {
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@PostMapping("/login")
|
|
|
- public AjaxResult login(@RequestBody LoginBody loginBody) {
|
|
|
- //校验租户状态?生成token
|
|
|
+ public AjaxResult login(@Valid @RequestBody LoginBody loginBody,BindingResult bindingResult) {
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ return AjaxResult.error(bindingResult.getFieldError().getDefaultMessage());
|
|
|
+ }
|
|
|
+ // 校验租户状态?生成token
|
|
|
AjaxResult ajax = AjaxResult.success();
|
|
|
// 生成令牌
|
|
|
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
|
|
loginBody.getUuid());
|
|
|
- //校验租户是否过期
|
|
|
+ // 校验租户是否过期
|
|
|
String checkTenantExpirationTimeMsg= loginService.checkTenantExpirationTime(loginBody);
|
|
|
if(!checkTenantExpirationTimeMsg.isEmpty()){
|
|
|
return AjaxResult.error(checkTenantExpirationTimeMsg);
|