|
|
|
@@ -1,12 +1,8 @@ |
|
|
|
package com.simple.controller; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import org.apache.shiro.SecurityUtils; |
|
|
|
import org.apache.shiro.authc.UsernamePasswordToken; |
|
|
|
import org.apache.shiro.subject.Subject; |
|
|
|
import org.omg.CORBA.SystemException; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
@@ -14,14 +10,13 @@ import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
import com.simple.common.ErrorCode; |
|
|
|
import com.simple.common.Result; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.simple.common.ResultData; |
|
|
|
import com.simple.domain.po.MallPermission; |
|
|
|
import com.simple.domain.po.MallRole; |
|
|
|
import com.simple.domain.po.MallRolePermission; |
|
|
|
import com.simple.domain.po.MallUserInfo; |
|
|
|
import com.simple.service.MallPermissionService; |
|
|
|
import com.simple.service.MallRoleService; |
|
|
|
import com.simple.domain.po.MallUserRole; |
|
|
|
import com.simple.service.MallRolePermissionService; |
|
|
|
import com.simple.service.MallUserRoleService; |
|
|
|
import com.simple.shiro.UserSession; |
|
|
|
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
@@ -32,11 +27,17 @@ import io.swagger.annotations.ApiOperation; |
|
|
|
@Api(description="登录相关接口") |
|
|
|
public class HomeController { |
|
|
|
|
|
|
|
// @Autowired |
|
|
|
// private MallRoleService sysRoleService; |
|
|
|
// |
|
|
|
// @Autowired |
|
|
|
// private MallPermissionService sysPermissionService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private MallRoleService sysRoleService; |
|
|
|
|
|
|
|
private MallUserRoleService mallUserRoleService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private MallPermissionService sysPermissionService; |
|
|
|
private MallRolePermissionService mallRolePermissionService; |
|
|
|
|
|
|
|
// @GetMapping("login") |
|
|
|
// public ResultData login() { |
|
|
|
@@ -64,7 +65,25 @@ public class HomeController { |
|
|
|
// } |
|
|
|
MallUserInfo info =(MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); |
|
|
|
info.setPassword("保密"); |
|
|
|
System.out.println("id:"+ SecurityUtils.getSubject().getSession().getId()); |
|
|
|
// System.out.println("id:"+ SecurityUtils.getSubject().getSession().getId()); |
|
|
|
MallUserRole ur = new MallUserRole(); |
|
|
|
ur.setUid(info.getId()); |
|
|
|
PageInfo<MallUserRole> page = mallUserRoleService.listAsPage(ur, 1, 1); |
|
|
|
if(page.getSize()>0) { |
|
|
|
Long roleId = page.getList().get(0).getRoleId(); |
|
|
|
MallRolePermission p = new MallRolePermission(); |
|
|
|
p.setRoleId(p.getRoleId()); |
|
|
|
p.setTenantId(info.getTenantId()); |
|
|
|
PageInfo<MallRolePermission> listAsPage = mallRolePermissionService.listAsPage(p, 1, 100); |
|
|
|
String menus = ""; |
|
|
|
for(MallRolePermission rp :listAsPage.getList()) { |
|
|
|
menus+=rp.getPermissionId()+","; |
|
|
|
} |
|
|
|
if(menus.length()>0) { |
|
|
|
menus = menus.substring(0, menus.length()-1); |
|
|
|
} |
|
|
|
info.setMenus(menus); |
|
|
|
} |
|
|
|
data.data=info; |
|
|
|
}catch(Exception e) { |
|
|
|
return new ResultData(ResultData.ERROR,"用户名或者密码错误"); |
|
|
|
|