|
@@ -8,7 +8,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.shiro.SecurityUtils;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.aspect.annotation.PermissionData;
|
|
@@ -21,6 +20,7 @@ import org.jeecg.common.util.PasswordUtil;
|
|
|
import org.jeecg.common.util.TokenUtils;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
|
|
|
+import org.jeecg.config.security.utils.SecureUtil;
|
|
|
import org.jeecg.modules.base.service.BaseCommonService;
|
|
|
import org.jeecg.modules.system.entity.*;
|
|
|
import org.jeecg.modules.system.service.ISysTenantPackService;
|
|
@@ -34,6 +34,7 @@ import org.jeecg.modules.system.vo.tenant.TenantPackModel;
|
|
|
import org.jeecg.modules.system.vo.tenant.TenantPackUser;
|
|
|
import org.jeecg.modules.system.vo.tenant.TenantPackUserCount;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@@ -75,7 +76,7 @@ public class SysTenantController {
|
|
|
* @param req
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequiresPermissions("system:tenant:list")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('system:tenant:list')")
|
|
|
@PermissionData(pageComponent = "system/TenantList")
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
|
public Result<IPage<SysTenant>> queryPageList(SysTenant sysTenant,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
@@ -114,7 +115,7 @@ public class SysTenantController {
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/recycleBinPageList")
|
|
|
- @RequiresPermissions("system:tenant:recycleBinPageList")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('system:tenant:recycleBinPageList')")
|
|
|
public Result<IPage<SysTenant>> recycleBinPageList(SysTenant sysTenant,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req){
|
|
|
Result<IPage<SysTenant>> result = new Result<IPage<SysTenant>>();
|
|
@@ -130,7 +131,7 @@ public class SysTenantController {
|
|
|
* @param
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequiresPermissions("system:tenant:add")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('system:tenant:add')")
|
|
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
|
|
public Result<SysTenant> add(@RequestBody SysTenant sysTenant) {
|
|
|
Result<SysTenant> result = new Result();
|
|
@@ -154,7 +155,7 @@ public class SysTenantController {
|
|
|
* @param
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequiresPermissions("system:tenant:edit")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('system:tenant:edit')")
|
|
|
@RequestMapping(value = "/edit", method ={RequestMethod.PUT, RequestMethod.POST})
|
|
|
public Result<SysTenant> edit(@RequestBody SysTenant tenant) {
|
|
|
Result<SysTenant> result = new Result();
|
|
@@ -177,14 +178,14 @@ public class SysTenantController {
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequiresPermissions("system:tenant:delete")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('system:tenant:delete')")
|
|
|
@RequestMapping(value = "/delete", method ={RequestMethod.DELETE, RequestMethod.POST})
|
|
|
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
//------------------------------------------------------------------
|
|
|
//如果是saas隔离的情况下,判断当前租户id是否是当前租户下的
|
|
|
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
|
|
|
//获取当前用户
|
|
|
- LoginUser sysUser = JSON.parseObject(SecurityContextHolder.getContext().getAuthentication().getName(), LoginUser.class);;
|
|
|
+ LoginUser sysUser = SecureUtil.currentUser();;
|
|
|
SysTenant sysTenant = sysTenantService.getById(id);
|
|
|
|
|
|
String username = "admin";
|
|
@@ -205,7 +206,7 @@ public class SysTenantController {
|
|
|
* @param ids
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequiresPermissions("system:tenant:deleteBatch")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('system:tenant:deleteBatch')")
|
|
|
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
|
|
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
Result<?> result = new Result<>();
|
|
@@ -220,7 +221,7 @@ public class SysTenantController {
|
|
|
//如果是saas隔离的情况下,判断当前租户id是否是当前租户下的
|
|
|
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
|
|
|
//获取当前用户
|
|
|
- LoginUser sysUser = JSON.parseObject(SecurityContextHolder.getContext().getAuthentication().getName(), LoginUser.class);;
|
|
|
+ LoginUser sysUser = SecureUtil.currentUser();
|
|
|
SysTenant sysTenant = sysTenantService.getById(id);
|
|
|
|
|
|
String username = "admin";
|
|
@@ -255,7 +256,7 @@ public class SysTenantController {
|
|
|
}
|
|
|
//------------------------------------------------------------------------------------------------
|
|
|
//获取登录用户信息
|
|
|
- LoginUser sysUser = JSON.parseObject(SecurityContextHolder.getContext().getAuthentication().getName(), LoginUser.class);;
|
|
|
+ LoginUser sysUser = SecureUtil.currentUser();
|
|
|
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】, admin给特权可以管理所有租户
|
|
|
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL && !"admin".equals(sysUser.getUsername())){
|
|
|
Integer loginSessionTenant = oConvertUtils.getInt(TenantContext.getTenant());
|
|
@@ -280,7 +281,7 @@ public class SysTenantController {
|
|
|
* 查询有效的 租户数据
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequiresPermissions("system:tenant:queryList")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('system:tenant:queryList')")
|
|
|
@RequestMapping(value = "/queryList", method = RequestMethod.GET)
|
|
|
public Result<List<SysTenant>> queryList(@RequestParam(name="ids",required=false) String ids) {
|
|
|
Result<List<SysTenant>> result = new Result<List<SysTenant>>();
|
|
@@ -306,7 +307,7 @@ public class SysTenantController {
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping(value = "/packList")
|
|
|
- @RequiresPermissions("system:tenant:packList")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('system:tenant:packList')")
|
|
|
public Result<IPage<SysTenantPack>> queryPackPageList(SysTenantPack sysTenantPack,
|
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
@@ -328,7 +329,7 @@ public class SysTenantController {
|
|
|
* @return
|
|
|
*/
|
|
|
@PostMapping(value = "/addPackPermission")
|
|
|
- @RequiresPermissions("system:tenant:add:pack")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('system:tenant:add:pack')")
|
|
|
public Result<String> addPackPermission(@RequestBody SysTenantPack sysTenantPack) {
|
|
|
sysTenantPackService.addPackPermission(sysTenantPack);
|
|
|
return Result.ok("创建租户产品包成功");
|
|
@@ -341,7 +342,7 @@ public class SysTenantController {
|
|
|
* @return
|
|
|
*/
|
|
|
@PutMapping(value = "/editPackPermission")
|
|
|
- @RequiresPermissions("system:tenant:edit:pack")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('system:tenant:edit:pack')")
|
|
|
public Result<String> editPackPermission(@RequestBody SysTenantPack sysTenantPack) {
|
|
|
sysTenantPackService.editPackPermission(sysTenantPack);
|
|
|
return Result.ok("修改租户产品包成功");
|
|
@@ -354,7 +355,7 @@ public class SysTenantController {
|
|
|
* @return
|
|
|
*/
|
|
|
@DeleteMapping("/deletePackPermissions")
|
|
|
- @RequiresPermissions("system:tenant:delete:pack")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('system:tenant:delete:pack')")
|
|
|
public Result<String> deletePackPermissions(@RequestParam(value = "ids") String ids) {
|
|
|
sysTenantPackService.deletePackPermissions(ids);
|
|
|
return Result.ok("删除租户产品包成功");
|
|
@@ -371,7 +372,7 @@ public class SysTenantController {
|
|
|
public Result<Map<String,Object>> getCurrentUserTenant() {
|
|
|
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
|
|
|
try {
|
|
|
- LoginUser sysUser = JSON.parseObject(SecurityContextHolder.getContext().getAuthentication().getName(), LoginUser.class);;
|
|
|
+ LoginUser sysUser = SecureUtil.currentUser();
|
|
|
//update-begin---author:wangshuai ---date:20221223 for:[QQYUN-3371]租户逻辑改造,改成关系表------------
|
|
|
List<Integer> tenantIdList = relationService.getTenantIdsByUserId(sysUser.getId());
|
|
|
Map<String,Object> map = new HashMap(5);
|
|
@@ -397,7 +398,7 @@ public class SysTenantController {
|
|
|
* @return
|
|
|
*/
|
|
|
@PutMapping("/invitationUserJoin")
|
|
|
- @RequiresPermissions("system:tenant:invitation:user")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('system:tenant:invitation:user')")
|
|
|
public Result<String> invitationUserJoin(@RequestParam("ids") String ids,@RequestParam("phone") String phone){
|
|
|
sysTenantService.invitationUserJoin(ids,phone);
|
|
|
return Result.ok("邀请用户成功");
|
|
@@ -412,7 +413,7 @@ public class SysTenantController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/getTenantUserList", method = RequestMethod.GET)
|
|
|
- @RequiresPermissions("system:tenant:user:list")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('system:tenant:user:list')")
|
|
|
public Result<IPage<SysUser>> getTenantUserList(SysUser user,
|
|
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
@@ -433,12 +434,12 @@ public class SysTenantController {
|
|
|
* @return
|
|
|
*/
|
|
|
@PutMapping("/leaveTenant")
|
|
|
- @RequiresPermissions("system:tenant:leave")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('system:tenant:leave')")
|
|
|
public Result<String> leaveTenant(@RequestParam("userIds") String userIds,
|
|
|
@RequestParam("tenantId") String tenantId){
|
|
|
Result<String> result = new Result<>();
|
|
|
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
|
|
- LoginUser sysUser = JSON.parseObject(SecurityContextHolder.getContext().getAuthentication().getName(), LoginUser.class);;
|
|
|
+ LoginUser sysUser = SecureUtil.currentUser();
|
|
|
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL && !"admin".equals(sysUser.getUsername())){
|
|
|
Integer loginSessionTenant = oConvertUtils.getInt(TenantContext.getTenant());
|
|
|
if(loginSessionTenant!=null && !loginSessionTenant.equals(Integer.valueOf(tenantId))){
|
|
@@ -484,7 +485,7 @@ public class SysTenantController {
|
|
|
@PostMapping("/saveTenantJoinUser")
|
|
|
public Result<Integer> saveTenantJoinUser(@RequestBody SysTenant sysTenant){
|
|
|
Result<Integer> result = new Result<>();
|
|
|
- LoginUser sysUser = JSON.parseObject(SecurityContextHolder.getContext().getAuthentication().getName(), LoginUser.class);;
|
|
|
+ LoginUser sysUser = SecureUtil.currentUser();
|
|
|
Integer tenantId = sysTenantService.saveTenantJoinUser(sysTenant, sysUser.getId());
|
|
|
result.setSuccess(true);
|
|
|
result.setMessage("创建成功");
|
|
@@ -498,7 +499,7 @@ public class SysTenantController {
|
|
|
*/
|
|
|
@PostMapping("/joinTenantByHouseNumber")
|
|
|
public Result<Integer> joinTenantByHouseNumber(@RequestBody SysTenant sysTenant){
|
|
|
- LoginUser sysUser = JSON.parseObject(SecurityContextHolder.getContext().getAuthentication().getName(), LoginUser.class);;
|
|
|
+ LoginUser sysUser = SecureUtil.currentUser();
|
|
|
Integer tenantId = sysTenantService.joinTenantByHouseNumber(sysTenant, sysUser.getId());
|
|
|
Result<Integer> result = new Result<>();
|
|
|
if(tenantId != 0){
|
|
@@ -533,7 +534,7 @@ public class SysTenantController {
|
|
|
SysUser user,
|
|
|
HttpServletRequest req) {
|
|
|
Page<SysUserTenantVo> page = new Page<SysUserTenantVo>(pageNo, pageSize);
|
|
|
- LoginUser sysUser = JSON.parseObject(SecurityContextHolder.getContext().getAuthentication().getName(), LoginUser.class);;
|
|
|
+ LoginUser sysUser = SecureUtil.currentUser();
|
|
|
String tenantId = oConvertUtils.getString(TenantContext.getTenant(), "0");
|
|
|
IPage<SysUserTenantVo> list = relationService.getUserTenantPageList(page, Arrays.asList(userTenantStatus.split(SymbolConstant.COMMA)), user, Integer.valueOf(tenantId));
|
|
|
return Result.ok(list);
|
|
@@ -548,7 +549,7 @@ public class SysTenantController {
|
|
|
@GetMapping("/getTenantListByUserId")
|
|
|
//@RequiresPermissions("system:tenant:getTenantListByUserId")
|
|
|
public Result<List<SysUserTenantVo>> getTenantListByUserId(@RequestParam(name = "userTenantStatus", required = false) String userTenantStatus) {
|
|
|
- LoginUser sysUser = JSON.parseObject(SecurityContextHolder.getContext().getAuthentication().getName(), LoginUser.class);;
|
|
|
+ LoginUser sysUser = SecureUtil.currentUser();
|
|
|
List<String> list = null;
|
|
|
if (oConvertUtils.isNotEmpty(userTenantStatus)) {
|
|
|
list = Arrays.asList(userTenantStatus.split(SymbolConstant.COMMA));
|
|
@@ -581,7 +582,7 @@ public class SysTenantController {
|
|
|
@PutMapping("/cancelTenant")
|
|
|
//@RequiresPermissions("system:tenant:cancelTenant")
|
|
|
public Result<String> cancelTenant(@RequestBody SysTenant sysTenant,HttpServletRequest request) {
|
|
|
- LoginUser sysUser = JSON.parseObject(SecurityContextHolder.getContext().getAuthentication().getName(), LoginUser.class);;
|
|
|
+ LoginUser sysUser = SecureUtil.currentUser();
|
|
|
SysTenant tenant = sysTenantService.getById(sysTenant.getId());
|
|
|
if (null == tenant) {
|
|
|
return Result.error("未找到当前租户信息");
|
|
@@ -624,7 +625,7 @@ public class SysTenantController {
|
|
|
*/
|
|
|
@PutMapping("/cancelApplyTenant")
|
|
|
public Result<String> cancelApplyTenant(@RequestParam("tenantId") String tenantId){
|
|
|
- LoginUser sysUser = JSON.parseObject(SecurityContextHolder.getContext().getAuthentication().getName(), LoginUser.class);;
|
|
|
+ LoginUser sysUser = SecureUtil.currentUser();
|
|
|
sysTenantService.leaveTenant(sysUser.getId(),tenantId);
|
|
|
return Result.ok("取消申请成功");
|
|
|
}
|
|
@@ -637,7 +638,7 @@ public class SysTenantController {
|
|
|
* @return
|
|
|
*/
|
|
|
@DeleteMapping("/deleteLogicDeleted")
|
|
|
- @RequiresPermissions("system:tenant:deleteTenantLogic")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('system:tenant:deleteTenantLogic')")
|
|
|
public Result<String> deleteTenantLogic(@RequestParam("ids") String ids){
|
|
|
sysTenantService.deleteTenantLogic(ids);
|
|
|
return Result.ok("彻底删除成功");
|
|
@@ -649,7 +650,7 @@ public class SysTenantController {
|
|
|
* @return
|
|
|
*/
|
|
|
@PutMapping("/revertTenantLogic")
|
|
|
- @RequiresPermissions("system:tenant:revertTenantLogic")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('system:tenant:revertTenantLogic')")
|
|
|
public Result<String> revertTenantLogic(@RequestParam("ids") String ids){
|
|
|
sysTenantService.revertTenantLogic(ids);
|
|
|
return Result.ok("还原成功");
|
|
@@ -663,7 +664,7 @@ public class SysTenantController {
|
|
|
*/
|
|
|
@DeleteMapping("/exitUserTenant")
|
|
|
public Result<String> exitUserTenant(@RequestBody SysTenant sysTenant,HttpServletRequest request){
|
|
|
- LoginUser sysUser = JSON.parseObject(SecurityContextHolder.getContext().getAuthentication().getName(), LoginUser.class);;
|
|
|
+ LoginUser sysUser = SecureUtil.currentUser();
|
|
|
//验证用户是否已存在
|
|
|
Integer count = relationService.userTenantIzExist(sysUser.getId(),sysTenant.getId());
|
|
|
if (count == 0) {
|
|
@@ -885,7 +886,7 @@ public class SysTenantController {
|
|
|
public Result<IPage<SysTenant>> getTenantPageListByUserId(SysUserTenantVo sysUserTenantVo,
|
|
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
|
|
|
- LoginUser sysUser = JSON.parseObject(SecurityContextHolder.getContext().getAuthentication().getName(), LoginUser.class);;
|
|
|
+ LoginUser sysUser = SecureUtil.currentUser();
|
|
|
List<String> list = null;
|
|
|
String userTenantStatus = sysUserTenantVo.getUserTenantStatus();
|
|
|
if (oConvertUtils.isNotEmpty(userTenantStatus)) {
|
|
@@ -903,7 +904,7 @@ public class SysTenantController {
|
|
|
public Result<String> agreeOrRefuseJoinTenant(@RequestParam("tenantId") Integer tenantId,
|
|
|
@RequestParam("status") String status){
|
|
|
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
|
|
- LoginUser sysUser = JSON.parseObject(SecurityContextHolder.getContext().getAuthentication().getName(), LoginUser.class);;
|
|
|
+ LoginUser sysUser = SecureUtil.currentUser();
|
|
|
String userId = sysUser.getId();
|
|
|
SysTenant tenant = sysTenantService.getById(tenantId);
|
|
|
if(null == tenant){
|