master:系统mapper中的sql 使用LEFT JOIN 的地方,转为JOIN

pull/1121/head
liujiang 2025-08-28 21:59:38 +08:00
parent a120039b22
commit 75b33d952f
15 changed files with 75 additions and 63 deletions

View File

@ -72,7 +72,7 @@ public class SysProductCategoryController extends XktBaseController {
return R.ok(BeanUtil.copyToList(prodCateService.tree(BeanUtil.toBean(listVO, ProdCateListDTO.class)), ProdCateListResVO.class));
}
@ApiOperation(value = "商品管理列表获取所有商品二级分类及没有二级分类的一级分类", httpMethod = "POST", response = R.class)
@ApiOperation(value = "商品管理列表获取所有商品二级分类及没有二级分类的一级分类", httpMethod = "GET", response = R.class)
@GetMapping("/leaf-node/list")
public R<List<ProdCateVO>> leafNodeList() {
return R.ok(BeanUtil.copyToList(prodCateService.leafNodeList(), ProdCateVO.class));

View File

@ -18,5 +18,7 @@ public class UserNoticePageVO extends BasePageVO {
@ApiModelProperty(value = "公告标题")
private String noticeTitle;
@ApiModelProperty(value = "公告类型1通知 2公告")
private Integer noticeType;
}

View File

@ -18,5 +18,7 @@ public class UserNoticePageDTO extends BasePageDTO {
@ApiModelProperty(value = "公告标题")
private String noticeTitle;
@ApiModelProperty(value = "公告类型1通知 2公告")
private Integer noticeType;
}

View File

@ -24,7 +24,9 @@ public interface UserNoticeMapper extends BaseMapper<UserNotice> {
* @param noticeTitle
* @return
*/
List<UserNoticeResDTO> selectUserNoticeList(@Param("userId") Long userId, @Param("noticeTitle") String noticeTitle);
List<UserNoticeResDTO> selectUserNoticeList(@Param("userId") Long userId,
@Param("noticeTitle") String noticeTitle,
@Param("noticeType") Integer noticeType);
/**
* APP

View File

@ -47,7 +47,7 @@ public class UserNoticeServiceImpl implements IUserNoticeService {
@Transactional(readOnly = true)
public Page<UserNoticeResDTO> pcPage(UserNoticePageDTO pageDTO) {
PageHelper.startPage(pageDTO.getPageNum(), pageDTO.getPageSize());
List<UserNoticeResDTO> list = this.userNoticeMapper.selectUserNoticeList(SecurityUtils.getUserId(), pageDTO.getNoticeTitle());
List<UserNoticeResDTO> list = this.userNoticeMapper.selectUserNoticeList(SecurityUtils.getUserId(), pageDTO.getNoticeTitle(), pageDTO.getNoticeType());
list.forEach(x -> x.setTargetNoticeTypeName(UserNoticeType.of(x.getTargetNoticeType()).getLabel()));
return Page.convert(new PageInfo<>(list));
}

View File

@ -1031,7 +1031,7 @@ public class WebsiteAPPServiceImpl implements IWebsiteAPPService {
.from((searchDTO.getPageNum() - 1) * searchDTO.getPageSize())
.size(searchDTO.getPageSize())
.sort(sort -> sort.field(f -> f.field("storeWeight").order(SortOrder.Desc)))
.sort(sort -> sort.field(f -> f.field(searchDTO.getSort()).order(SortOrder.Desc))),
.sort(sort -> sort.field(f -> f.field(searchDTO.getSort()).order(searchDTO.getOrder()))),
ESProductDTO.class);
final long total = resList.hits().total().value();
final List<ESProductDTO> esProdList = resList.hits().hits().stream().map(x -> x.source().setStoreProdId(x.id())).collect(Collectors.toList());

View File

@ -12,8 +12,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sf.file_url
FROM
advert_store_file ssf
LEFT JOIN sys_file sf ON ssf.pic_id = sf.id
LEFT JOIN store s ON ssf.store_id = s.id
JOIN sys_file sf ON ssf.pic_id = sf.id
JOIN store s ON ssf.store_id = s.id
WHERE
ssf.del_flag = 0
<if test="storeName != null and storeName != ''">

View File

@ -110,9 +110,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
scpd.update_time
FROM
store_customer_product_discount scpd
LEFT JOIN store_product sp ON scpd.store_prod_id = sp.id
LEFT JOIN store_product_color spc ON scpd.store_prod_color_id = spc.id
LEFT JOIN store_product_color_price spcp ON spc.store_prod_id = spcp.store_prod_id
JOIN store_product sp ON scpd.store_prod_id = sp.id
JOIN store_product_color spc ON scpd.store_prod_color_id = spc.id
JOIN store_product_color_price spcp ON spc.store_prod_id = spcp.store_prod_id
AND spc.store_color_id = spcp.store_color_id
WHERE
scpd.del_flag = 0 AND scpd.store_id = #{storeId}

View File

@ -13,7 +13,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
*
FROM
store_product_category_attribute
WHERE del_flag = 0 AND store_prod_id = #{storeProdId}
WHERE
del_flag = 0 AND store_prod_id = #{storeProdId}
</select>

View File

@ -39,8 +39,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
spcp.store_prod_id,
MIN( spcp.price )
FROM
store_product_color_price spcp JOIN store_product_color spc ON spcp.store_prod_id = spc.store_prod_id
AND spcp.store_color_id = spc.store_color_id AND spc.prod_status IN ( 2, 3 )
store_product_color_price spcp
JOIN store_product_color spc ON spcp.store_prod_id = spc.store_prod_id
AND spcp.store_color_id = spc.store_color_id AND spc.prod_status IN ( 2, 3 )
WHERE
spcp.del_flag = 0
<if test="storeProdIdList != null and storeProdIdList.size() > 0">

View File

@ -34,9 +34,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
( SELECT discount FROM store_customer_product_discount WHERE store_cus_id = #{storeCusId} AND store_prod_color_id = spc.id AND del_flag = 0 ) AS discount
FROM
store_product_color_size spcs
LEFT JOIN store_product_color_price spcp ON spcs.store_prod_id = spcp.store_prod_id AND spcs.store_color_id = spcp.store_color_id AND spcp.del_flag = 0
LEFT JOIN store_product sp ON spcs.store_prod_id = sp.id
LEFT JOIN store_product_color spc ON spcs.store_color_id = spc.store_color_id AND spcs.store_prod_id = spc.store_prod_id AND spc.del_flag = 0
JOIN store_product_color_price spcp ON spcs.store_prod_id = spcp.store_prod_id AND spcs.store_color_id = spcp.store_color_id AND spcp.del_flag = 0
JOIN store_product sp ON spcs.store_prod_id = sp.id
JOIN store_product_color spc ON spcs.store_color_id = spc.store_color_id AND spcs.store_prod_id = spc.store_prod_id AND spc.del_flag = 0
WHERE
spcs.del_flag = 0
AND spcs.sn_prefix = #{snPrefix}
@ -56,9 +56,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
( SELECT discount FROM store_customer_product_discount WHERE store_cus_id = #{storeCusId} AND store_prod_color_id = spc.id AND del_flag = 0 ) AS discount
FROM
store_product_color_size spcs
LEFT JOIN store_product_color_price spcp ON spcs.store_prod_id = spcp.store_prod_id AND spcs.store_color_id = spcp.store_color_id AND spcp.del_flag = 0
LEFT JOIN store_product sp ON spcs.store_prod_id = sp.id
LEFT JOIN store_product_color spc ON spcs.store_color_id = spc.store_color_id AND spcs.store_prod_id = spc.store_prod_id AND spc.del_flag = 0
JOIN store_product_color_price spcp ON spcs.store_prod_id = spcp.store_prod_id AND spcs.store_color_id = spcp.store_color_id AND spcp.del_flag = 0
JOIN store_product sp ON spcs.store_prod_id = sp.id
JOIN store_product_color spc ON spcs.store_color_id = spc.store_color_id AND spcs.store_prod_id = spc.store_prod_id AND spc.del_flag = 0
WHERE
spcs.del_flag = 0
AND spcs.other_sn_prefix = #{snPrefix}
@ -77,8 +77,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
spcs.sn_prefix AS prefixPart
FROM
store_product_color_size spcs
JOIN store_product sp ON spcs.store_prod_id = sp.id
JOIN store_product_color spc ON spcs.store_color_id = spc.store_color_id AND spcs.store_prod_id = spc.store_prod_id AND spc.del_flag = 0
JOIN store_product sp ON spcs.store_prod_id = sp.id
JOIN store_product_color spc ON spcs.store_color_id = spc.store_color_id AND spcs.store_prod_id = spc.store_prod_id AND spc.del_flag = 0
WHERE
spcs.del_flag = 0
AND sp.store_id = #{storeId}
@ -102,8 +102,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
spcs.other_sn_prefix AS prefixPart
FROM
store_product_color_size spcs
JOIN store_product sp ON spcs.store_prod_id = sp.id
JOIN store_product_color spc ON spcs.store_color_id = spc.store_color_id AND spcs.store_prod_id = spc.store_prod_id AND spc.del_flag = 0
JOIN store_product sp ON spcs.store_prod_id = sp.id
JOIN store_product_color spc ON spcs.store_color_id = spc.store_color_id AND spcs.store_prod_id = spc.store_prod_id AND spc.del_flag = 0
WHERE
spcs.del_flag = 0
AND sp.store_id = #{storeId}
@ -124,8 +124,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
spcs.sn_prefix AS prefixPart
FROM
store_product_color_size spcs
JOIN store_product sp ON spcs.store_prod_id = sp.id
JOIN store_product_color spc ON spcs.store_color_id = spc.store_color_id AND spcs.store_prod_id = spc.store_prod_id AND spc.del_flag = 0
JOIN store_product sp ON spcs.store_prod_id = sp.id
JOIN store_product_color spc ON spcs.store_color_id = spc.store_color_id AND spcs.store_prod_id = spc.store_prod_id AND spc.del_flag = 0
WHERE
spcs.del_flag = 0
<if test="buJuPrefixSnList != null and buJuPrefixSnList.size() > 0">
@ -145,8 +145,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
spcs.other_sn_prefix AS prefixPart
FROM
store_product_color_size spcs
JOIN store_product sp ON spcs.store_prod_id = sp.id
JOIN store_product_color spc ON spcs.store_color_id = spc.store_color_id AND spcs.store_prod_id = spc.store_prod_id AND spc.del_flag = 0
JOIN store_product sp ON spcs.store_prod_id = sp.id
JOIN store_product_color spc ON spcs.store_color_id = spc.store_color_id AND spcs.store_prod_id = spc.store_prod_id AND spc.del_flag = 0
WHERE
spcs.del_flag = 0
<if test="otherPrefixSnList != null and otherPrefixSnList.size() > 0">

View File

@ -30,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sf.file_url AS fileUrl
FROM
store_product_file spf
LEFT JOIN sys_file sf ON spf.file_id = sf.id
JOIN sys_file sf ON spf.file_id = sf.id
WHERE
spf.del_flag = 0
<if test="storeProdIdList != null and storeProdIdList.size() > 0">
@ -54,8 +54,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sf.file_url AS fileUrl
FROM
store_product_file spf
LEFT JOIN sys_file sf ON spf.file_id = sf.id
LEFT JOIN store_product sp ON spf.store_prod_id = sp.id
JOIN sys_file sf ON spf.file_id = sf.id
JOIN store_product sp ON spf.store_prod_id = sp.id
WHERE
spf.del_flag = 0
AND spf.file_type = #{fileType}
@ -83,7 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
spf.order_num AS orderNum
FROM
store_product_file spf
LEFT JOIN sys_file sf ON spf.file_id = sf.id
JOIN sys_file sf ON spf.file_id = sf.id
WHERE
spf.del_flag = 0
AND spf.file_type = #{fileType}
@ -95,8 +95,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
spf.store_prod_id,
sf.file_url
FROM
store_product_file spf LEFT JOIN store_product sp ON spf.store_prod_id = sp.id
LEFT JOIN sys_file sf ON spf.file_id = sf.id
store_product_file spf
JOIN store_product sp ON spf.store_prod_id = sp.id
JOIN sys_file sf ON spf.file_id = sf.id
WHERE
spf.del_flag = 0
AND spf.file_type = 1
@ -116,9 +117,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ROW_NUMBER() OVER ( PARTITION BY spf.store_id ORDER BY spf.create_time DESC ) AS rank_num
FROM
store_product_file spf
LEFT JOIN store_product sp ON spf.store_prod_id = sp.id
LEFT JOIN sys_file sf ON spf.file_id = sf.id
LEFT JOIN store s ON spf.store_id = s.id
JOIN store_product sp ON spf.store_prod_id = sp.id
JOIN sys_file sf ON spf.file_id = sf.id
JOIN store s ON spf.store_id = s.id
WHERE
spf.del_flag = 0
AND spf.file_type = 1
@ -147,7 +148,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
spf.order_num
FROM
store_product_file spf
LEFT JOIN sys_file sf ON spf.file_id = sf.id
JOIN sys_file sf ON spf.file_id = sf.id
WHERE
spf.del_flag = 0
AND spf.store_prod_id = #{storeProdId}

View File

@ -38,12 +38,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
spc2.`name` AS parCateName
FROM
store_product sp
LEFT JOIN store s ON sp.store_id = s.id
LEFT JOIN store_product_file spf ON sp.id = spf.store_prod_id AND spf.del_flag = 0 AND spf.file_type = 1 AND spf.order_num = 1
LEFT JOIN sys_file sf ON spf.file_id = sf.id
LEFT JOIN store_product_category_attribute spca ON sp.id = spca.store_prod_id
LEFT JOIN sys_product_category spc1 ON sp.prod_cate_id = spc1.id
LEFT JOIN sys_product_category spc2 ON spc1.parent_id = spc2.id
JOIN store s ON sp.store_id = s.id
JOIN store_product_file spf ON sp.id = spf.store_prod_id AND spf.del_flag = 0 AND spf.file_type = 1 AND spf.order_num = 1
JOIN sys_file sf ON spf.file_id = sf.id
JOIN store_product_category_attribute spca ON sp.id = spca.store_prod_id
JOIN sys_product_category spc1 ON sp.prod_cate_id = spc1.id
JOIN sys_product_category spc2 ON spc1.parent_id = spc2.id
LEFT JOIN ( SELECT store_prod_id, MIN( price ) AS min_price FROM store_product_color_price GROUP BY store_prod_id ) spcp ON sp.id = spcp.store_prod_id
WHERE
sp.del_flag = 0 AND sp.id IN
@ -80,8 +80,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
spcs.id AS store_prod_color_size_id
FROM
store_product_color spc
LEFT JOIN store_product_color_price spcp ON spc.store_color_id = spcp.store_color_id AND spc.store_prod_id = spcp.store_prod_id AND spcp.del_flag = 0
LEFT JOIN store_product_color_size spcs ON spc.store_color_id = spcs.store_color_id AND spc.store_prod_id = spcs.store_prod_id AND spcs.del_flag = 0
JOIN store_product_color_price spcp ON spc.store_color_id = spcp.store_color_id AND spc.store_prod_id = spcp.store_prod_id AND spcp.del_flag = 0
JOIN store_product_color_size spcs ON spc.store_color_id = spcs.store_color_id AND spc.store_prod_id = spcs.store_prod_id AND spcs.del_flag = 0
WHERE
spc.del_flag = 0
AND spc.prod_status IN (2,3)
@ -98,9 +98,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
MIN( spcp.price ) AS minPrice
FROM
store_product sp
LEFT JOIN store_product_color_price spcp ON sp.id = spcp.store_prod_id
LEFT JOIN store_product_file spf ON sp.id = spf.store_prod_id AND spf.del_flag = 0 AND spf.file_type = 1 AND spf.order_num = 1
LEFT JOIN sys_file sf ON spf.file_id = sf.id
JOIN store_product_color_price spcp ON sp.id = spcp.store_prod_id
JOIN store_product_file spf ON sp.id = spf.store_prod_id AND spf.del_flag = 0 AND spf.file_type = 1 AND spf.order_num = 1
JOIN sys_file sf ON spf.file_id = sf.id
WHERE
sp.del_flag = 0
AND sp.prod_status IN (2,3)
@ -131,12 +131,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
EXISTS( SELECT 1 FROM store_product_file spf2 WHERE spf2.store_prod_id = sp.id AND spf2.del_flag = 0 AND spf2.file_type = 2 LIMIT 1 ) AS hasVideo
FROM
store_product sp
LEFT JOIN store_product_color_price spcp ON sp.id = spcp.store_prod_id
LEFT JOIN store_product_file spf ON sp.id = spf.store_prod_id AND spf.del_flag = 0 AND spf.file_type = 1 AND spf.order_num = 1
LEFT JOIN sys_file sf ON spf.file_id = sf.id
LEFT JOIN store s ON sp.store_id = s.id
JOIN store_product_color_price spcp ON sp.id = spcp.store_prod_id
JOIN store_product_file spf ON sp.id = spf.store_prod_id AND spf.del_flag = 0 AND spf.file_type = 1 AND spf.order_num = 1
JOIN sys_file sf ON spf.file_id = sf.id
JOIN store s ON sp.store_id = s.id
JOIN sys_product_category spc ON sp.prod_cate_id = spc.id
LEFT JOIN daily_prod_tag dpt ON sp.id = dpt.store_prod_id AND dpt.del_flag = 0
LEFT JOIN sys_product_category spc ON sp.prod_cate_id = spc.id
WHERE
sp.del_flag = 0
AND sp.prod_status IN (2,3)
@ -241,8 +241,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
EXISTS ( SELECT 1 FROM user_favorites uf WHERE sp.id = uf.store_prod_id AND uf.del_flag = 0 AND uf.user_id = #{userId} ) AS collectProd
FROM
store_product sp
LEFT JOIN store_product_detail spd ON sp.id = spd.store_prod_id AND spd.del_flag = 0
LEFT JOIN store s ON sp.store_id = s.id
JOIN store_product_detail spd ON sp.id = spd.store_prod_id AND spd.del_flag = 0
JOIN store s ON sp.store_id = s.id
WHERE
sp.del_flag = 0
AND sp.id = #{storeProdId}
@ -271,7 +271,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
COUNT( sp.id ) AS cateCount
FROM
store_product sp
LEFT JOIN sys_product_category spc ON sp.prod_cate_id = spc.id
JOIN sys_product_category spc ON sp.prod_cate_id = spc.id
WHERE
sp.del_flag = 0
AND sp.store_id = #{storeId}
@ -298,10 +298,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
FROM
store_product sp
LEFT JOIN store s ON sp.store_id = s.id
LEFT JOIN store_product_color_price spcp ON sp.id = spcp.store_prod_id AND spcp.del_flag = 0
JOIN store s ON sp.store_id = s.id
JOIN store_product_detail spd ON sp.id = spd.store_prod_id AND spd.del_flag = 0
JOIN store_product_color_price spcp ON sp.id = spcp.store_prod_id AND spcp.del_flag = 0
LEFT JOIN daily_prod_tag dpt ON sp.id = dpt.store_prod_id AND dpt.del_flag = 0
LEFT JOIN store_product_detail spd ON sp.id = spd.store_prod_id AND spd.del_flag = 0
WHERE
sp.del_flag = 0 AND sp.id = #{storeProdId}
GROUP BY

View File

@ -30,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
IFNULL(sps.size_38, 0) + IFNULL(sps.size_39, 0) + IFNULL(sps.size_40, 0) + IFNULL(sps.size_41, 0) +
IFNULL(sps.size_42, 0) + IFNULL(sps.size_43, 0)) AS totalStock
FROM
store_product_stock sps left join store_product sp on sps.store_prod_id = sp.id left join sys_product_category spc on sp.prod_cate_id = spc.id
store_product_stock sps join store_product sp on sps.store_prod_id = sp.id join sys_product_category spc on sp.prod_cate_id = spc.id
WHERE
sps.del_flag = 0
<if test="prodArtNum != null and prodArtNum != ''"> and sps.prod_art_num like concat('%', #{prodArtNum}, '%')</if>
@ -52,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
IFNULL(sps.size_38, 0) + IFNULL(sps.size_39, 0) + IFNULL(sps.size_40, 0) + IFNULL(sps.size_41, 0) +
IFNULL(sps.size_42, 0) + IFNULL(sps.size_43, 0)) AS totalStock
FROM
store_product_stock sps left join store_product sp on sps.store_prod_id = sp.id left join sys_product_category spc on sp.prod_cate_id = spc.id
store_product_stock sps join store_product sp on sps.store_prod_id = sp.id join sys_product_category spc on sp.prod_cate_id = spc.id
WHERE
sps.del_flag = 0
AND sps.store_id = #{storeId}

View File

@ -17,12 +17,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
n.perpetuity
FROM
user_notice un
LEFT JOIN notice n ON un.notice_id = n.id
JOIN notice n ON un.notice_id = n.id
WHERE
un.del_flag = 0
<if test="noticeTitle != null and noticeTitle != ''">
AND n.notice_title LIKE concat('%', #{noticeTitle}, '%')
</if>
<if test="noticeType != null">
AND n.notice
</if>
AND un.user_id = #{userId}
ORDER BY
un.create_time DESC,
@ -37,7 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
un.read_status
FROM
user_notice un
LEFT JOIN notice n ON un.notice_id = n.id
JOIN notice n ON un.notice_id = n.id
WHERE
un.del_flag = 0 AND un.user_id = #{userId}
ORDER BY
@ -51,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
un.create_time
FROM
user_notice un
LEFT JOIN notice n ON un.notice_id = n.id
JOIN notice n ON un.notice_id = n.id
WHERE
un.del_flag = 0
AND un.target_notice_type = #{targetNoticeType}