|
@@ -5,6 +5,7 @@ import java.util.Set;
|
|
|
|
|
|
import com.zkqy.common.core.domain.entity.DataSource;
|
|
|
import com.zkqy.common.core.domain.entity.SysTenant;
|
|
|
+import com.zkqy.framework.web.service.TokenService;
|
|
|
import com.zkqy.system.service.IDataSourceService;
|
|
|
import com.zkqy.system.service.impl.SysTenantServiceImpl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -50,6 +51,8 @@ public class SysLoginController {
|
|
|
|
|
|
@Resource
|
|
|
private IDataSourceService dataSourceService;
|
|
|
+ @Resource
|
|
|
+ private TokenService tokenService;
|
|
|
|
|
|
/**
|
|
|
* 数据引擎切换数据源接口地址
|
|
@@ -74,11 +77,41 @@ public class SysLoginController {
|
|
|
|
|
|
/**
|
|
|
* 登录方法
|
|
|
+ *
|
|
|
* @param loginBody 登录信息
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@PostMapping("/login")
|
|
|
- public AjaxResult login(@Valid @RequestBody LoginBody loginBody,BindingResult bindingResult) {
|
|
|
+ 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());
|
|
|
+ if (tokenService.getLoginUserIsAdminByToken(token)) {
|
|
|
+ return AjaxResult.error("用户不存在!");
|
|
|
+ }
|
|
|
+ // 校验租户是否过期
|
|
|
+ String checkTenantExpirationTimeMsg = loginService.checkTenantExpirationTime(loginBody);
|
|
|
+ if (!checkTenantExpirationTimeMsg.isEmpty()) {
|
|
|
+ return AjaxResult.error(checkTenantExpirationTimeMsg);
|
|
|
+ }
|
|
|
+ ajax.put(Constants.TOKEN, token);
|
|
|
+ return ajax;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 登录方法
|
|
|
+ *
|
|
|
+ * @param loginBody 登录信息
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @PostMapping("/loginadmin")
|
|
|
+ public AjaxResult loginadmin(@Valid @RequestBody LoginBody loginBody, BindingResult bindingResult) {
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
return AjaxResult.error(bindingResult.getFieldError().getDefaultMessage());
|
|
|
}
|
|
@@ -88,14 +121,15 @@ public class SysLoginController {
|
|
|
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
|
|
loginBody.getUuid());
|
|
|
// 校验租户是否过期
|
|
|
- String checkTenantExpirationTimeMsg= loginService.checkTenantExpirationTime(loginBody);
|
|
|
- if(!checkTenantExpirationTimeMsg.isEmpty()){
|
|
|
+ String checkTenantExpirationTimeMsg = loginService.checkTenantExpirationTime(loginBody);
|
|
|
+ if (!checkTenantExpirationTimeMsg.isEmpty()) {
|
|
|
return AjaxResult.error(checkTenantExpirationTimeMsg);
|
|
|
}
|
|
|
ajax.put(Constants.TOKEN, token);
|
|
|
return ajax;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 获取用户信息
|
|
|
*
|