当前位置: 首页> 健康> 科研 > 怎样创建网站桌面快捷方式_软件技术买什么笔记本好_水平优化_西安专业seo

怎样创建网站桌面快捷方式_软件技术买什么笔记本好_水平优化_西安专业seo

时间:2025/7/9 6:13:16来源:https://blog.csdn.net/m0_65152767/article/details/144247347 浏览次数:0次
怎样创建网站桌面快捷方式_软件技术买什么笔记本好_水平优化_西安专业seo

文章目录

  • 1、ProductController
  • 2、AdminCommonService
  • 3、ProductApiService
  • 4、ProductCommonService
  • 5、ProductSqlService
      • 1. 完整SQL分析
        • 可选部分(条件筛选):
      • 2. 涉及的表
      • 3. 总结
      • 4. 功能概述

查询指定管理员下所有产品所涉及的表?

SELECT * FROM `brand_admin_mapping` WHERE `admin_id`  = 75;SELECT * FROM `product` WHERE `brand_id` = 30SELECT * FROM `product` WHERE `brand_id` = 40SELECT * FROM `product_admin_mapping` WHERE `admin_id` = 75
 http://127.0.0.1:8087/product/admin/list?page=0&size=10&field=name

1、ProductController

    @GetMapping("admin/list")@ApiOperation("分页列表")public BaseResult list(PageWithSearch basePage, @ApiIgnore @SessionAttribute(Constants.ADMIN_ID) Integer adminId) {checkParam(basePage.getField(), basePage.getValue());adminId = adminCommonService.getVipIdByProduct(adminId);return BaseResult.success(productApiService.findPage(adminId, basePage));}

2、AdminCommonService

    /*** 获取商品管理人的上级vip id* 当操作者为商品管理人时获取上级的vip id* 否则返回自身*/public Integer getVipIdByProduct(Integer nowId) {return hasRole(nowId, Admin.ROLE_PRODUCT) || hasRole(nowId, Admin.ROLE_QUALIFICATION) || hasRole(nowId, Admin.ROLE_STORE) ? findCompanySuperId(nowId) : nowId;}/*** 查询公司超管id*/public Integer findCompanySuperId(Integer adminId) {return adminService.findCompanySuperId(adminId);}

3、ProductApiService

    /*** 分页列表*/public Page<ProductListDto> findPage(Integer nowId, PageWithSearch page) {Page<ProductWithShareDto> productPage = productCommonService.findPage(nowId, page);return new PageImpl<>(convertToListDto(productPage.getContent(), nowId), page.toPageable(), productPage.getTotalElements());}

4、ProductCommonService

    /*** 产品管理-产品分页列表*/public Page<ProductWithShareDto> findPage(Integer nowId, PageWithSearch basePage) {return productSqlService.findPage(nowId, basePage);}

5、ProductSqlService

    /*** 产品管理-分页列表*/public Page<ProductWithShareDto> findPage(Integer nowId, PageWithSearch basePage) {StringBuilder sql = new StringBuilder();Map<String, Object> paramMap = new HashMap<>(4);sql.append("SELECT DISTINCT ").append(SqlUtil.sqlGenerate("p", Product.class)).append(",a.send_id, a.edit_auth FROM product p ");if (!StringUtils.isEmpty(basePage.getField()) && !StringUtils.isEmpty(basePage.getValue()) && brandParamStr.contains(basePage.getField())) {sql.append("INNER JOIN brand b ON p.brand_id = b.id AND b.").append(SqlUtil.camelToUnderline(basePage.getField().replaceAll("brand", ""))).append(" LIKE :").append(basePage.getField()).append(" ");paramMap.put(basePage.getField(), "%" + basePage.getValue() + "%");}//sql.append("LEFT JOIN product_admin_mapping a ON p.id = a.product_id ");//sql.append("AND a.admin_id=").append(nowId).append(" AND a.read_auth =").append(CommonStatusEnum.NORMAL.getValue()).append(" ");//sql.append("WHERE (p.creator_id =").append(nowId).append(" OR ").append("a.id IS NOT NULL) ");sql.append("INNER JOIN product_admin_mapping a ON p.id = a.product_id AND a.admin_id=").append(nowId).append(" ");//有编辑权限 || (有查看权限 && 产品状态为显示)sql.append("WHERE (a.edit_auth =").append(CommonStatusEnum.NORMAL.getValue()).append(" OR (a.read_auth =").append(CommonStatusEnum.NORMAL.getValue()).append(" AND p.status =").append(CommonStatusEnum.NORMAL.getValue()).append(")) ");paramHandle(sql, paramMap, basePage.getField(), basePage.getValue());sql.append("ORDER BY p.ranks DESC,p.created_date DESC ");List result = executeSql(sql, paramMap, basePage.getPage(), basePage.getSize());if (result.isEmpty()) {return new PageImpl<>(Collections.emptyList(), basePage.toPageable(), 0);}return new PageImpl<>(parseToProductWithShare(result), basePage.toPageable(), countPage(nowId, basePage.getField(), basePage.getValue()));}

1. 完整SQL分析

从代码中生成的SQL大致如下:

SELECT DISTINCT p.*, a.send_id, a.edit_auth 
FROM product p 
INNER JOIN product_admin_mapping a ON p.id = a.product_id AND a.admin_id = :nowId

条件部分:

WHERE (a.edit_auth = :normalStatus OR (a.read_auth = :normalStatus AND p.status = :normalStatus))

排序部分:

ORDER BY p.ranks DESC, p.created_date DESC
可选部分(条件筛选):

basePage.getField()basePage.getValue() 存在时:

INNER JOIN brand b ON p.brand_id = b.id AND b.<转换后的字段> LIKE :fieldValue

2. 涉及的表

  1. product:产品表(p
  2. product_admin_mapping:产品与管理员权限映射表(a
  3. brand(条件存在时):品牌表(b

3. 总结

最终SQL根据逻辑最多涉及 3张表

  1. product
  2. product_admin_mapping
  3. brand(可选)

4. 功能概述

  • 基于管理员ID (nowId) 和搜索条件筛选产品。
  • 关联管理员权限(编辑或查看权限)。
  • 按照产品的排名和创建时间排序返回分页结果。

在这里插入图片描述

关键字:怎样创建网站桌面快捷方式_软件技术买什么笔记本好_水平优化_西安专业seo

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: