feat(goods): 更新产品列表查询功能
- 移除单个租户 ID 参数,改为接收租户 ID 列表 - 在 SQL 中添加对多个租户 ID 的 IN 查询 - 优化服务实现,使用 TenantHelper 忽略租户权限 - 调整日志标题,提高可读性
This commit is contained in:
parent
46a6f340fd
commit
8af8137fec
@ -1,5 +1,6 @@
|
||||
package com.wzj.soopin.goods.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -9,6 +10,8 @@ import com.wzj.soopin.goods.domain.vo.ProductVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.dromara.common.mybatis.annotation.DataColumn;
|
||||
import org.dromara.common.mybatis.annotation.DataPermission;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -28,7 +31,9 @@ public interface ProductMapper extends BaseMapper<Product> {
|
||||
*/
|
||||
List<Product> selectByEntity(Product product);
|
||||
|
||||
IPage<ProductVO> getlist(@Param("page") Page<Product> page, @Param("query") ProductBo query,String tenantId);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
IPage<ProductVO> getlist(@Param("page") Page<Product> page, @Param("query") ProductBo query, @Param("tenantIds") List<String> tenantIds);
|
||||
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.wzj.soopin.goods.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.wzj.soopin.goods.domain.bo.ProductBo;
|
||||
@ -23,6 +24,7 @@ import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -44,8 +46,10 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
@Override
|
||||
public IPage<ProductVO> getList(ProductBo query, Page<Product> page) {
|
||||
|
||||
String tenantId = LoginHelper.getTenantId();
|
||||
IPage<ProductVO> getlist = productMapper.getlist(page, query, tenantId);
|
||||
// todo 获取当前登录人被分配的,可管理的商铺租户id
|
||||
List<String> tenantIds = TenantHelper.ignore(() -> productMapper.selectList(Wrappers.lambdaQuery(Product.class)).stream().map(Product::getTenantId).toList());
|
||||
|
||||
IPage<ProductVO> getlist = TenantHelper.ignore(() -> productMapper.getlist(page, query, tenantIds));
|
||||
return getlist;
|
||||
}
|
||||
|
||||
@ -55,8 +59,10 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
|
||||
//推荐商品要根据算法获取
|
||||
|
||||
String tenantId = LoginHelper.getTenantId();
|
||||
return productMapper.getlist(page,new ProductBo(),tenantId);
|
||||
// todo 获取当前登录人被分配的,可管理的商铺租户id
|
||||
List<String> tenantIds = new ArrayList<>();
|
||||
|
||||
return productMapper.getlist(page,new ProductBo(), tenantIds);
|
||||
}
|
||||
|
||||
public Product audit(Long id, Integer authFlag, String reasons) {
|
||||
|
@ -78,9 +78,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
LEFT JOIN pms_product_category pc ON p.category_id = pc.id
|
||||
LEFT JOIN pms_sku s ON p.id = s.product_id
|
||||
WHERE 1=1
|
||||
<!-- <if test="tenantId != '000000'">-->
|
||||
<!-- AND s.tenant_id = #{tenantId}-->
|
||||
<!-- </if>-->
|
||||
<if test="query.nameLike != null and query.nameLike != ''">
|
||||
AND p.name LIKE CONCAT('%', #{query.nameLike}, '%')
|
||||
</if>
|
||||
@ -99,6 +96,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="query.categoryId != null">
|
||||
AND p.category_id = #{query.categoryId}
|
||||
</if>
|
||||
<if test="tenantIds != null and tenantIds.size() > 0">
|
||||
AND p.tenant_id IN
|
||||
<foreach collection="tenantIds" item="tenantId" open="(" separator="," close=")">
|
||||
#{tenantId}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
ORDER BY
|
||||
p.sales DESC,
|
||||
p.price ASC,
|
||||
|
@ -116,7 +116,7 @@ public class SysPostController extends BaseController {
|
||||
* @param postIds 岗位ID串
|
||||
* @param deptId 部门id
|
||||
*/
|
||||
@SaCheckPermission("system:post:query")
|
||||
// @SaCheckPermission("system:post:query")
|
||||
@GetMapping("/optionselect")
|
||||
public R<List<SysPostVo>> optionselect(@RequestParam(required = false) Long[] postIds, @RequestParam(required = false) Long deptId) {
|
||||
List<SysPostVo> list = new ArrayList<>();
|
||||
|
@ -94,7 +94,7 @@ public class SysTenantController extends BaseController {
|
||||
*/
|
||||
// @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:add")
|
||||
@Log(title = "租户管理", businessType = BusinessType.INSERT)
|
||||
@Log(title = "新增租户", businessType = BusinessType.INSERT)
|
||||
@Lock4j
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/add")
|
||||
@ -110,7 +110,7 @@ public class SysTenantController extends BaseController {
|
||||
*/
|
||||
// @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:edit")
|
||||
@Log(title = "租户管理", businessType = BusinessType.UPDATE)
|
||||
@Log(title = "修改租户", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/update")
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysTenantExtendBo bo) {
|
||||
@ -138,7 +138,7 @@ public class SysTenantController extends BaseController {
|
||||
* 提交签约
|
||||
*/
|
||||
@SaCheckPermission("system:tenant:submitSign")
|
||||
@Log(title = "租户管理", businessType = BusinessType.UPDATE)
|
||||
@Log(title = "提交签约", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/submitSign/{tenantId}")
|
||||
public R<Void> submitSign(@PathVariable String tenantId) {
|
||||
tenantService.checkTenantAllowed(tenantId);
|
||||
@ -149,7 +149,7 @@ public class SysTenantController extends BaseController {
|
||||
* 审核提交的签约
|
||||
*/
|
||||
@SaCheckPermission("system:tenant:reviewSubmitted")
|
||||
@Log(title = "租户管理", businessType = BusinessType.UPDATE)
|
||||
@Log(title = "审核提交的签约", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/reviewSubmitted")
|
||||
public R<Void> reviewSubmitted(@RequestBody SysTenantReviewBo bo) {
|
||||
tenantService.checkTenantAllowed(bo.getTenantId());
|
||||
|
Loading…
x
Reference in New Issue
Block a user