|
|
@@ -3,7 +3,6 @@ package cn.iocoder.byzs.module.web.controller.admin.login;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.byzs.framework.common.enums.CommonStatusEnum;
|
|
|
import cn.iocoder.byzs.framework.common.pojo.CommonResult;
|
|
|
-import cn.iocoder.byzs.framework.common.util.json.JsonUtils;
|
|
|
import cn.iocoder.byzs.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.byzs.framework.security.config.SecurityProperties;
|
|
|
import cn.iocoder.byzs.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
@@ -22,7 +21,9 @@ import cn.iocoder.byzs.module.system.service.dict.DictDataService;
|
|
|
import cn.iocoder.byzs.module.system.service.permission.PermissionService;
|
|
|
import cn.iocoder.byzs.module.system.service.permission.RoleService;
|
|
|
import cn.iocoder.byzs.module.system.service.tenant.TenantService;
|
|
|
-import cn.iocoder.byzs.module.web.controller.admin.login.vo.AuthLoginVO;
|
|
|
+import cn.iocoder.byzs.module.web.controller.admin.login.vo.WebLoginVO;
|
|
|
+import cn.iocoder.byzs.module.web.controller.admin.login.vo.WebRegisterVO;
|
|
|
+import cn.iocoder.byzs.module.web.service.login.WebLoginServiceImpl;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
@@ -34,7 +35,6 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -57,6 +57,8 @@ public class WebLoginController {
|
|
|
private RoleService roleService;
|
|
|
@Resource
|
|
|
private DictDataService dictDataService;
|
|
|
+ @Resource
|
|
|
+ private WebLoginServiceImpl webLoginServiceImpl;
|
|
|
|
|
|
|
|
|
@GetMapping("/getTenantIdByName")
|
|
|
@@ -69,17 +71,25 @@ public class WebLoginController {
|
|
|
return success(tenant != null ? tenant.getId() : null);
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/register")
|
|
|
+ @PermitAll
|
|
|
+ @Operation(summary = "注册租户")
|
|
|
+ public CommonResult<Boolean> register(@RequestBody @Valid WebRegisterVO reqVO) {
|
|
|
+ Long register = webLoginServiceImpl.register(reqVO);
|
|
|
+ return success(register != null);
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("/login")
|
|
|
@PermitAll
|
|
|
@Operation(summary = "使用账号密码登录")
|
|
|
- public CommonResult<AuthLoginVO> login(@RequestBody @Valid AuthLoginReqVO reqVO) {
|
|
|
+ public CommonResult<WebLoginVO> login(@RequestBody @Valid AuthLoginReqVO reqVO) {
|
|
|
return success(setAuthRoleVO(authService.login(reqVO)));
|
|
|
}
|
|
|
|
|
|
@PostMapping("/sms-login")
|
|
|
@PermitAll
|
|
|
@Operation(summary = "使用短信验证码登录")
|
|
|
- public CommonResult<AuthLoginVO> smsLogin(@RequestBody @Valid AuthSmsLoginReqVO reqVO) {
|
|
|
+ public CommonResult<WebLoginVO> smsLogin(@RequestBody @Valid AuthSmsLoginReqVO reqVO) {
|
|
|
return success(setAuthRoleVO(authService.smsLogin(reqVO)));
|
|
|
}
|
|
|
|
|
|
@@ -131,12 +141,12 @@ public class WebLoginController {
|
|
|
* @param login
|
|
|
* @return
|
|
|
*/
|
|
|
- private AuthLoginVO setAuthRoleVO(AuthLoginRespVO login) {
|
|
|
- AuthLoginVO authLoginVO = BeanUtils.toBean(login, AuthLoginVO.class);
|
|
|
+ private WebLoginVO setAuthRoleVO(AuthLoginRespVO login) {
|
|
|
+ WebLoginVO webLoginVO = BeanUtils.toBean(login, WebLoginVO.class);
|
|
|
|
|
|
// 已经在后台读取,这里无需重复读取
|
|
|
if (true) {
|
|
|
- return authLoginVO;
|
|
|
+ return webLoginVO;
|
|
|
}
|
|
|
|
|
|
// 获得角色列表
|
|
|
@@ -161,8 +171,8 @@ public class WebLoginController {
|
|
|
}
|
|
|
|
|
|
//填充课程数据权限
|
|
|
- authLoginVO.setCourseDataScope(allDataScopeCourseIds);
|
|
|
- authLoginVO.setBlocklyDataScope(allDataScopeBlocklyIds);
|
|
|
- return authLoginVO;
|
|
|
+ webLoginVO.setCourseDataScope(allDataScopeCourseIds);
|
|
|
+ webLoginVO.setBlocklyDataScope(allDataScopeBlocklyIds);
|
|
|
+ return webLoginVO;
|
|
|
}
|
|
|
}
|