|
@@ -26,7 +26,6 @@ import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.SearchResult;
|
|
import com.ejlchina.searcher.SearchResult;
|
|
|
import com.ejlchina.searcher.util.MapBuilder;
|
|
import com.ejlchina.searcher.util.MapBuilder;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -87,7 +86,6 @@ public class ExchangeCodeController {
|
|
|
@GetMapping("/get")
|
|
@GetMapping("/get")
|
|
|
@SaCheckPermission("exchangeCode:view")
|
|
@SaCheckPermission("exchangeCode:view")
|
|
|
public Result<SearchResult<ExchangeCodeView>> getExchangeCodeView(Long goodsId, Long skuId) {
|
|
public Result<SearchResult<ExchangeCodeView>> getExchangeCodeView(Long goodsId, Long skuId) {
|
|
|
- long adminId = StpUtil.getLoginIdAsLong();
|
|
|
|
|
String condition = StrUtil.EMPTY;
|
|
String condition = StrUtil.EMPTY;
|
|
|
if (goodsId != null) {
|
|
if (goodsId != null) {
|
|
|
condition = String.format(" and JSON_CONTAINS(goods_ids,'%s')", goodsId);
|
|
condition = String.format(" and JSON_CONTAINS(goods_ids,'%s')", goodsId);
|
|
@@ -95,7 +93,7 @@ public class ExchangeCodeController {
|
|
|
if (skuId != null) {
|
|
if (skuId != null) {
|
|
|
condition += String.format(" and JSON_CONTAINS(sku_ids,'%s')", skuId);
|
|
condition += String.format(" and JSON_CONTAINS(sku_ids,'%s')", skuId);
|
|
|
}
|
|
}
|
|
|
- MapBuilder builder = safeSearchBuilder(condition, adminId);
|
|
|
|
|
|
|
+ MapBuilder builder = safeSearchBuilder(condition);
|
|
|
SearchResult<ExchangeCodeView> search = beanSearcher.search(ExchangeCodeView.class, builder.build());
|
|
SearchResult<ExchangeCodeView> search = beanSearcher.search(ExchangeCodeView.class, builder.build());
|
|
|
search.getDataList().forEach(data -> {
|
|
search.getDataList().forEach(data -> {
|
|
|
try {
|
|
try {
|
|
@@ -119,7 +117,8 @@ public class ExchangeCodeController {
|
|
|
@SaCheckPermission("exchangeCode:export")
|
|
@SaCheckPermission("exchangeCode:export")
|
|
|
@Log(module = "兑换码/导出", businessType = BusinessType.POST, isSaveRequestData = true)
|
|
@Log(module = "兑换码/导出", businessType = BusinessType.POST, isSaveRequestData = true)
|
|
|
public void exportExchangeCode(HttpServletResponse response, Long goodsId, Long skuId) {
|
|
public void exportExchangeCode(HttpServletResponse response, Long goodsId, Long skuId) {
|
|
|
- long adminId = StpUtil.getLoginIdAsLong();
|
|
|
|
|
|
|
+ response.setHeader("Cache-Control", "no-store, private");
|
|
|
|
|
+ response.setHeader("Pragma", "no-cache");
|
|
|
String condition = StrUtil.EMPTY;
|
|
String condition = StrUtil.EMPTY;
|
|
|
if (goodsId != null) {
|
|
if (goodsId != null) {
|
|
|
condition = String.format(" and JSON_CONTAINS(goods_ids,'%s')", goodsId);
|
|
condition = String.format(" and JSON_CONTAINS(goods_ids,'%s')", goodsId);
|
|
@@ -127,7 +126,7 @@ public class ExchangeCodeController {
|
|
|
if (skuId != null) {
|
|
if (skuId != null) {
|
|
|
condition += String.format(" and JSON_CONTAINS(sku_ids,'%s')", skuId);
|
|
condition += String.format(" and JSON_CONTAINS(sku_ids,'%s')", skuId);
|
|
|
}
|
|
}
|
|
|
- MapBuilder builder = safeSearchBuilder(condition, adminId);
|
|
|
|
|
|
|
+ MapBuilder builder = safeSearchBuilder(condition);
|
|
|
if (beanSearcher.searchCount(ExcelExchangeCodeData.class, builder.build()).longValue() > 10000) {
|
|
if (beanSearcher.searchCount(ExcelExchangeCodeData.class, builder.build()).longValue() > 10000) {
|
|
|
throw BusinessRuntimeException.getInstance("每次最多导出10000条,请缩小查询范围");
|
|
throw BusinessRuntimeException.getInstance("每次最多导出10000条,请缩小查询范围");
|
|
|
}
|
|
}
|
|
@@ -136,7 +135,7 @@ public class ExchangeCodeController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 不透传请求参数:condition、字段操作符、逻辑分组均不能由客户端指定。
|
|
// 不透传请求参数:condition、字段操作符、逻辑分组均不能由客户端指定。
|
|
|
- private MapBuilder safeSearchBuilder(String condition, long adminId) {
|
|
|
|
|
|
|
+ private MapBuilder safeSearchBuilder(String condition) {
|
|
|
MapBuilder builder = MapUtils.builder().put("condition", condition);
|
|
MapBuilder builder = MapUtils.builder().put("condition", condition);
|
|
|
String code = request.getParameter("code");
|
|
String code = request.getParameter("code");
|
|
|
if (StrUtil.isNotBlank(code)) builder.field(ExchangeCodeView::getCode, code);
|
|
if (StrUtil.isNotBlank(code)) builder.field(ExchangeCodeView::getCode, code);
|
|
@@ -151,15 +150,6 @@ public class ExchangeCodeController {
|
|
|
}
|
|
}
|
|
|
String codeType = request.getParameter("codeType");
|
|
String codeType = request.getParameter("codeType");
|
|
|
if (StrUtil.isNotBlank(codeType)) builder.field(ExchangeCodeView::getCodeType, Integer.valueOf(codeType));
|
|
if (StrUtil.isNotBlank(codeType)) builder.field(ExchangeCodeView::getCodeType, Integer.valueOf(codeType));
|
|
|
- if (!StpUtil.hasRole("root")) {
|
|
|
|
|
- CmsUser admin = cmsUserMapper.selectById(adminId);
|
|
|
|
|
- if (admin == null || StrUtil.isBlank(admin.getNickname())
|
|
|
|
|
- || cmsUserMapper.selectCount(Wrappers.lambdaQuery(CmsUser.class)
|
|
|
|
|
- .eq(CmsUser::getNickname, admin.getNickname())) != 1) {
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("创建人信息不唯一,请联系管理员核实数据归属");
|
|
|
|
|
- }
|
|
|
|
|
- builder.field(ExchangeCodeView::getOperator, admin.getNickname());
|
|
|
|
|
- }
|
|
|
|
|
int page = request.getParameter("start") == null ? 1 : Integer.parseInt(request.getParameter("start"));
|
|
int page = request.getParameter("start") == null ? 1 : Integer.parseInt(request.getParameter("start"));
|
|
|
int size = request.getParameter("limit") == null ? 10 : Integer.parseInt(request.getParameter("limit"));
|
|
int size = request.getParameter("limit") == null ? 10 : Integer.parseInt(request.getParameter("limit"));
|
|
|
if (page < 1 || size < 1 || size > 100) throw BusinessRuntimeException.getInstance("分页参数错误");
|
|
if (page < 1 || size < 1 || size > 100) throw BusinessRuntimeException.getInstance("分页参数错误");
|