!833 修改:CRM 产品,产品列表查询接入数据权限

Merge pull request !833 from 安浩浩/develop
This commit is contained in:
芋道源码 2024-01-15 04:33:16 +00:00 committed by Gitee
commit cc6cb83507
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 20 additions and 12 deletions

View File

@ -42,6 +42,7 @@ import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_PRODUCT_TYPE;
@Tag(name = "管理后台 - CRM 产品")
@ -102,7 +103,7 @@ public class CrmProductController {
@Operation(summary = "获得产品分页")
@PreAuthorize("@ss.hasPermission('crm:product:query')")
public CommonResult<PageResult<CrmProductRespVO>> getProductPage(@Valid CrmProductPageReqVO pageVO) {
PageResult<CrmProductDO> pageResult = productService.getProductPage(pageVO);
PageResult<CrmProductDO> pageResult = productService.getProductPage(pageVO, getLoginUserId());
return success(new PageResult<>(getProductDetailList(pageResult.getList()), pageResult.getTotal()));
}
@ -113,7 +114,7 @@ public class CrmProductController {
public void exportProductExcel(@Valid CrmProductPageReqVO exportReqVO,
HttpServletResponse response) throws IOException {
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<CrmProductDO> list = productService.getProductPage(exportReqVO).getList();
List<CrmProductDO> list = productService.getProductPage(exportReqVO, getLoginUserId()).getList();
// 导出 Excel
ExcelUtils.write(response, "产品.xls", "数据", CrmProductRespVO.class,
getProductDetailList(list));

View File

@ -2,9 +2,11 @@ package cn.iocoder.yudao.module.crm.dal.mysql.product;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO;
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils;
import org.apache.ibatis.annotations.Mapper;
/**
@ -15,11 +17,17 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CrmProductMapper extends BaseMapperX<CrmProductDO> {
default PageResult<CrmProductDO> selectPage(CrmProductPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<CrmProductDO>()
default PageResult<CrmProductDO> selectPage(CrmProductPageReqVO reqVO, Long userId) {
MPJLambdaWrapperX<CrmProductDO> query = new MPJLambdaWrapperX<>();
// 拼接数据权限的查询条件
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_PRODUCT.getType(),
CrmProductDO::getId, userId, null, Boolean.FALSE);
// 拼接自身的查询条件
query.selectAll(CrmProductDO.class)
.likeIfPresent(CrmProductDO::getName, reqVO.getName())
.eqIfPresent(CrmProductDO::getStatus, reqVO.getStatus())
.orderByDesc(CrmProductDO::getId));
.orderByDesc(CrmProductDO::getId);
return selectJoinPage(reqVO, CrmProductDO.class, query);
}
default CrmProductDO selectByNo(String no) {

View File

@ -4,8 +4,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO;
import jakarta.validation.Valid;
import java.util.Collection;
import java.util.List;
@ -60,7 +60,7 @@ public interface CrmProductService {
* @param pageReqVO 分页查询
* @return 产品分页
*/
PageResult<CrmProductDO> getProductPage(CrmProductPageReqVO pageReqVO);
PageResult<CrmProductDO> getProductPage(CrmProductPageReqVO pageReqVO, Long userId);
/**
* 获得产品

View File

@ -145,10 +145,9 @@ public class CrmProductServiceImpl implements CrmProductService {
return productMapper.selectBatchIds(ids);
}
// TODO @anhaohao可以接入数据权限参考 CrmCustomerService getCustomerPage
@Override
public PageResult<CrmProductDO> getProductPage(CrmProductPageReqVO pageReqVO) {
return productMapper.selectPage(pageReqVO);
public PageResult<CrmProductDO> getProductPage(CrmProductPageReqVO pageReqVO, Long userId) {
return productMapper.selectPage(pageReqVO, userId);
}
@Override