廖井涛
20 分钟以前 f7a2fcdda7f1120498c5c5f75c5a99955fc54b43
north-glass-erp/src/main/java/com/example/erp/service/sd/ProductService.java
@@ -7,6 +7,7 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.example.erp.common.Constants;
import com.example.erp.dto.sd.OrderSearchDTO;
import com.example.erp.entity.sd.Product;
import com.example.erp.entity.sd.ProductDetail;
import com.example.erp.entity.userInfo.Log;
@@ -37,14 +38,27 @@
        this.logService = logService;
    }
    //产品查询方法
    public Map<String,Object> defaultDateProduct(Integer pageNum, Integer pageSize, List<String> glassType, Product product) {
    public Map<String,Object> defaultDateProduct(Integer pageNum, Integer pageSize, List<String> glassType,Map<String,Object> config) {
        Integer offset = (pageNum-1)*pageSize;
        String glassTypeId = null;
        if(glassType.size()>1){
            glassTypeId = glassType.get(1);
        if(glassType.size()==2){
            if(!Objects.equals(glassType.get(0), "")&&!Objects.equals(glassType.get(1), "")){
                glassTypeId = glassType.get(1);
            }
        }else if(glassType.size()==1){
            if(!Objects.equals(glassType.get(0), "")&& !Objects.equals(glassType.get(0), "undefined")){
                glassTypeId = glassType.get(0);
            }
        }
        JSONObject orderJson = new JSONObject(config);
        Product product = JSONObject.parseObject(JSONObject.toJSONString(orderJson.get("filter")), Product.class);
        Map<String,String> sortDate = (Map<String, String>) config.get("sort");
        String field = sortDate.get("field").replaceAll("(?<!^)([A-Z])", "_$1").toLowerCase();
        String orderBy = sortDate.get("order");
        Map<String,Object> map = new HashMap<>();
        map.put("data",productMapper.defaultProduct(offset,pageSize,glassTypeId,product));
        map.put("data",productMapper.defaultProduct(offset,pageSize,glassTypeId,product,field, orderBy));
        map.put("total",productMapper.getPageTotal(offset,pageSize,glassTypeId,product));
        return map;
    }