mirror of https://gitee.com/stylefeng/roses
【7.6.0】【sys】【portal】更新获取用户常用功能的接口
parent
486a4b134b
commit
616bf10208
|
@ -1,11 +1,11 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.userapp.controller;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.menu.UserAppMenuInfo;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.userapp.entity.PortalUserApp;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.userapp.pojo.request.PortalUserAppRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.userapp.service.PortalUserAppService;
|
||||
|
@ -30,72 +30,27 @@ public class PortalUserAppController {
|
|||
private PortalUserAppService portalUserAppService;
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* 获取用户常用功能
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/06/26 21:25
|
||||
*/
|
||||
@PostResource(name = "添加", path = "/portalUserApp/add")
|
||||
public ResponseData<PortalUserApp> add(@RequestBody @Validated(PortalUserAppRequest.add.class) PortalUserAppRequest portalUserAppRequest) {
|
||||
portalUserAppService.add(portalUserAppRequest);
|
||||
@GetResource(name = "获取用户常用功能", path = "/portalUserApp/getUserAppList")
|
||||
public ResponseData<List<UserAppMenuInfo>> getUserAppList() {
|
||||
return new SuccessResponseData<>(portalUserAppService.getUserAppList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户的常用功能
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/06/26 21:25
|
||||
*/
|
||||
@PostResource(name = "添加", path = "/portalUserApp/updateUserAppList")
|
||||
public ResponseData<PortalUserApp> updateUserAppList(
|
||||
@RequestBody @Validated(PortalUserAppRequest.add.class) PortalUserAppRequest portalUserAppRequest) {
|
||||
portalUserAppService.updateUserAppList(portalUserAppRequest);
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/06/26 21:25
|
||||
*/
|
||||
@PostResource(name = "删除", path = "/portalUserApp/delete")
|
||||
public ResponseData<?> delete(@RequestBody @Validated(PortalUserAppRequest.delete.class) PortalUserAppRequest portalUserAppRequest) {
|
||||
portalUserAppService.del(portalUserAppRequest);
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/06/26 21:25
|
||||
*/
|
||||
@PostResource(name = "编辑", path = "/portalUserApp/edit")
|
||||
public ResponseData<?> edit(@RequestBody @Validated(PortalUserAppRequest.edit.class) PortalUserAppRequest portalUserAppRequest) {
|
||||
portalUserAppService.edit(portalUserAppRequest);
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看详情
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/06/26 21:25
|
||||
*/
|
||||
@GetResource(name = "查看详情", path = "/portalUserApp/detail")
|
||||
public ResponseData<PortalUserApp> detail(@Validated(PortalUserAppRequest.detail.class) PortalUserAppRequest portalUserAppRequest) {
|
||||
return new SuccessResponseData<>(portalUserAppService.detail(portalUserAppRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/06/26 21:25
|
||||
*/
|
||||
@GetResource(name = "获取列表", path = "/portalUserApp/list")
|
||||
public ResponseData<List<PortalUserApp>> list(PortalUserAppRequest portalUserAppRequest) {
|
||||
return new SuccessResponseData<>(portalUserAppService.findList(portalUserAppRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列表(带分页)
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/06/26 21:25
|
||||
*/
|
||||
@GetResource(name = "分页查询", path = "/portalUserApp/page")
|
||||
public ResponseData<PageResult<PortalUserApp>> page(PortalUserAppRequest portalUserAppRequest) {
|
||||
return new SuccessResponseData<>(portalUserAppService.findPage(portalUserAppRequest));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,13 @@ public class PortalUserApp extends BaseEntity {
|
|||
@ChineseDescription("主键id")
|
||||
private Long appLinkId;
|
||||
|
||||
/**
|
||||
* 所属用户id
|
||||
*/
|
||||
@TableField("user_id")
|
||||
@ChineseDescription("所属用户id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 冗余字段,菜单所属的应用id
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.userapp.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.menu.UserAppMenuInfo;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.userapp.entity.PortalUserApp;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.userapp.pojo.request.PortalUserAppRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
@ -15,60 +15,22 @@ import java.util.List;
|
|||
*/
|
||||
public interface PortalUserAppService extends IService<PortalUserApp> {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
/**
|
||||
* 更新用户的常用功能
|
||||
*
|
||||
* @param portalUserAppRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/06/26 21:25
|
||||
*/
|
||||
void add(PortalUserAppRequest portalUserAppRequest);
|
||||
void updateUserAppList(PortalUserAppRequest portalUserAppRequest);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param portalUserAppRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/06/26 21:25
|
||||
*/
|
||||
void del(PortalUserAppRequest portalUserAppRequest);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param portalUserAppRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/06/26 21:25
|
||||
*/
|
||||
void edit(PortalUserAppRequest portalUserAppRequest);
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*
|
||||
* @param portalUserAppRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/06/26 21:25
|
||||
*/
|
||||
PortalUserApp detail(PortalUserAppRequest portalUserAppRequest);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @param portalUserAppRequest 请求参数
|
||||
* @return List<PortalUserApp> 返回结果
|
||||
* @author fengshuonan
|
||||
* @date 2023/06/26 21:25
|
||||
*/
|
||||
List<PortalUserApp> findList(PortalUserAppRequest portalUserAppRequest);
|
||||
|
||||
/**
|
||||
* 获取列表(带分页)
|
||||
*
|
||||
* @param portalUserAppRequest 请求参数
|
||||
* @return PageResult<PortalUserApp> 返回结果
|
||||
* @author fengshuonan
|
||||
* @date 2023/06/26 21:25
|
||||
*/
|
||||
PageResult<PortalUserApp> findPage(PortalUserAppRequest portalUserAppRequest);
|
||||
List<UserAppMenuInfo> getUserAppList();
|
||||
|
||||
}
|
|
@ -2,21 +2,22 @@ package cn.stylefeng.roses.kernel.sys.modular.userapp.service.impl;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
||||
import cn.stylefeng.roses.kernel.sys.api.SysMenuServiceApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.menu.UserAppMenuInfo;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.userapp.entity.PortalUserApp;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.userapp.enums.PortalUserAppExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.userapp.mapper.PortalUserAppMapper;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.userapp.pojo.request.PortalUserAppRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.userapp.service.PortalUserAppService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户常用功能业务实现层
|
||||
|
@ -27,78 +28,37 @@ import java.util.List;
|
|||
@Service
|
||||
public class PortalUserAppServiceImpl extends ServiceImpl<PortalUserAppMapper, PortalUserApp> implements PortalUserAppService {
|
||||
|
||||
@Override
|
||||
public void add(PortalUserAppRequest portalUserAppRequest) {
|
||||
@Resource
|
||||
private SysMenuServiceApi sysMenuServiceApi;
|
||||
|
||||
@Override
|
||||
public void updateUserAppList(PortalUserAppRequest portalUserAppRequest) {
|
||||
PortalUserApp portalUserApp = new PortalUserApp();
|
||||
BeanUtil.copyProperties(portalUserAppRequest, portalUserApp);
|
||||
this.save(portalUserApp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void del(PortalUserAppRequest portalUserAppRequest) {
|
||||
PortalUserApp portalUserApp = this.queryPortalUserApp(portalUserAppRequest);
|
||||
this.removeById(portalUserApp.getAppLinkId());
|
||||
}
|
||||
public List<UserAppMenuInfo> getUserAppList() {
|
||||
|
||||
@Override
|
||||
public void edit(PortalUserAppRequest portalUserAppRequest) {
|
||||
PortalUserApp portalUserApp = this.queryPortalUserApp(portalUserAppRequest);
|
||||
BeanUtil.copyProperties(portalUserAppRequest, portalUserApp);
|
||||
this.updateById(portalUserApp);
|
||||
}
|
||||
// 获取当前登录用户id
|
||||
Long userId = LoginContext.me().getLoginUser().getUserId();
|
||||
|
||||
@Override
|
||||
public PortalUserApp detail(PortalUserAppRequest portalUserAppRequest) {
|
||||
return this.queryPortalUserApp(portalUserAppRequest);
|
||||
}
|
||||
// 获取所有的用户常用功能(功能其实对应的就是菜单)
|
||||
LambdaQueryWrapper<PortalUserApp> portalUserAppLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
portalUserAppLambdaQueryWrapper.eq(PortalUserApp::getUserId, userId);
|
||||
portalUserAppLambdaQueryWrapper.select(PortalUserApp::getMenuId);
|
||||
List<PortalUserApp> userAppList = this.list(portalUserAppLambdaQueryWrapper);
|
||||
|
||||
@Override
|
||||
public PageResult<PortalUserApp> findPage(PortalUserAppRequest portalUserAppRequest) {
|
||||
LambdaQueryWrapper<PortalUserApp> wrapper = createWrapper(portalUserAppRequest);
|
||||
Page<PortalUserApp> sysRolePage = this.page(PageFactory.defaultPage(), wrapper);
|
||||
return PageResultFactory.createPageResult(sysRolePage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PortalUserApp> findList(PortalUserAppRequest portalUserAppRequest) {
|
||||
LambdaQueryWrapper<PortalUserApp> wrapper = this.createWrapper(portalUserAppRequest);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/06/26 21:25
|
||||
*/
|
||||
private PortalUserApp queryPortalUserApp(PortalUserAppRequest portalUserAppRequest) {
|
||||
PortalUserApp portalUserApp = this.getById(portalUserAppRequest.getAppLinkId());
|
||||
if (ObjectUtil.isEmpty(portalUserApp)) {
|
||||
throw new ServiceException(PortalUserAppExceptionEnum.PORTAL_USER_APP_NOT_EXISTED);
|
||||
if (ObjectUtil.isEmpty(userAppList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return portalUserApp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建查询wrapper
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/06/26 21:25
|
||||
*/
|
||||
private LambdaQueryWrapper<PortalUserApp> createWrapper(PortalUserAppRequest portalUserAppRequest) {
|
||||
LambdaQueryWrapper<PortalUserApp> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// 获取这些功能的菜单id集合
|
||||
Set<Long> totalMenuIdList = userAppList.stream().map(PortalUserApp::getMenuId).collect(Collectors.toSet());
|
||||
|
||||
Long appLinkId = portalUserAppRequest.getAppLinkId();
|
||||
Long appId = portalUserAppRequest.getAppId();
|
||||
Long menuId = portalUserAppRequest.getMenuId();
|
||||
Long tenantId = portalUserAppRequest.getTenantId();
|
||||
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(appLinkId), PortalUserApp::getAppLinkId, appLinkId);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(appId), PortalUserApp::getAppId, appId);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(menuId), PortalUserApp::getMenuId, menuId);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(tenantId), PortalUserApp::getTenantId, tenantId);
|
||||
|
||||
return queryWrapper;
|
||||
// 通过这些菜单id查询到菜单的名称、图标、路由返回给前端
|
||||
return sysMenuServiceApi.getUserAppMenuDetailList(totalMenuIdList);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue