|
@@ -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;
|
|
@@ -49,6 +50,9 @@ public class SysLoginController {
|
|
|
@Resource
|
|
|
private SysTenantServiceImpl sysTenantService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private TokenService tokenService;
|
|
|
+
|
|
|
//@Resource
|
|
|
//private IDataSourceService dataSourceService;
|
|
|
|
|
@@ -87,15 +91,47 @@ public class SysLoginController {
|
|
|
//校验租户状态?生成token
|
|
|
AjaxResult ajax = AjaxResult.success();
|
|
|
//校验不能是admin
|
|
|
- if(loginBody.getUsername().equals("admin")){
|
|
|
- return AjaxResult.error("未有此用户信息");
|
|
|
+ if (loginBody.getUsername().equals("admin")) {
|
|
|
+ return AjaxResult.error("未有此用户信息");
|
|
|
+ }
|
|
|
+ // 生成令牌
|
|
|
+ String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
|
|
+ loginBody.getUuid());
|
|
|
+ if (tokenService.getLoginUserIsAdminByToken(token)) {
|
|
|
+ return AjaxResult.error("用户不存在!");
|
|
|
+ }
|
|
|
+ //检查租户过期时间
|
|
|
+ String checkTenantExpirationTimeMsg = loginService.checkTenantExpirationTime(loginBody.getUsername());
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ //校验租户状态?生成token
|
|
|
+ AjaxResult ajax = AjaxResult.success();
|
|
|
+ //校验不能是admin
|
|
|
+ if (loginBody.getUsername().equals("admin")) {
|
|
|
+ return AjaxResult.error("未有此用户信息");
|
|
|
}
|
|
|
// 生成令牌
|
|
|
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
|
|
loginBody.getUuid());
|
|
|
//检查租户过期时间
|
|
|
- String checkTenantExpirationTimeMsg= loginService.checkTenantExpirationTime(loginBody.getUsername());
|
|
|
- if(!checkTenantExpirationTimeMsg.isEmpty()){
|
|
|
+ String checkTenantExpirationTimeMsg = loginService.checkTenantExpirationTime(loginBody.getUsername());
|
|
|
+ if (!checkTenantExpirationTimeMsg.isEmpty()) {
|
|
|
return AjaxResult.error(checkTenantExpirationTimeMsg);
|
|
|
}
|
|
|
ajax.put(Constants.TOKEN, token);
|