java 在json中获取空响应

d8tt03nd  于 2023-01-01  发布在  Java
关注(0)|答案(1)|浏览(120)

我有一个现有的项目中,我必须添加过滤器“dealername”。我已经实现了它,但其他值给响应为空。
控制器API i具有-

@PostMapping("/getJobcardDetails")
    @ResponseBody
    @LogExecution
    public ResponseEntity<?> getJobcardDetails(@RequestBody  DealerRequest request) {
        try {
            Object response = null;
            response = service.getJobcardDetails(request);
            if (response != null) {
                return new ResponseEntity<>(
                        new Response(Constants.SUCCESS_CODE, Constants.SUCCESS, Constants.DATA_FOUND, response),
                        HttpStatus.OK);
            } else {
                return new ResponseEntity<>(new Response(Constants.SUCCESS_CODE, Constants.SUCCESS,
                        Constants.NO_DATA_FOUND, Constants.SUCCESS), HttpStatus.OK);
            }
        } catch (Exception e) {
            logger.error("Exception in getDistinctValues(): ", e);
            return new ResponseEntity<>(new Response(Constants.ERROR_CODE, Constants.ERROR, Constants.INTERNAL_SERVER,
                    Constants.INTERNAL_SERVER), HttpStatus.INTERNAL_SERVER_ERROR);
        }

    }

服务实现,其中我添加了筛选器-

public Object getJobcardDetails(DealerRequest request) throws Exception {
        
        String clause = " where jc.dealer_code = dm.code ";
        String AND_CLAUSE = " and ";
        String WHERE_CLAUSE = " where ";
        try {
            if (!TextUtils.isEmpty(request.getCity())) {
                if (!clause.isEmpty()) {
                    clause += AND_CLAUSE;
                } else {
                    clause += WHERE_CLAUSE;
                }
                clause += " dm.city = '" + request.getCity() + "'";
            }
            if (!TextUtils.isEmpty(request.getRegion())) {
                if (!clause.isEmpty()) {
                    clause += AND_CLAUSE;
                } else {
                    clause += WHERE_CLAUSE;
                }
                clause += " dm.region = '" +request.getRegion()+ "'";
            }
            if (!TextUtils.isEmpty(request.getState())) {
                if (!clause.isEmpty()) {
                    clause += AND_CLAUSE;
                } else {
                    clause += WHERE_CLAUSE;
                }
                clause += "dm.state = '" +request.getState()+ "'";
            }
            if (!TextUtils.isEmpty(request.getType())) {
                if (!clause.isEmpty()) {
                    clause += AND_CLAUSE;
                } else {
                    clause += WHERE_CLAUSE;
                }
                clause += " dm.type = '" +request.getType()+ "'";
            }
            if (!TextUtils.isEmpty(request.getJcType())) {
                if (!clause.isEmpty()) {
                    clause += AND_CLAUSE;
                } else {
                    clause += WHERE_CLAUSE;
                }
                clause += " jc.js_type_desc = '" +request.getJcType()+ "'";
            }
            if (!TextUtils.isEmpty(request.getdealername())) {
                if (!clause.isEmpty()) {
                    clause += AND_CLAUSE;
                } else {
                    clause += WHERE_CLAUSE;
                }
                clause += " jc.dealername = '" +request.getdealername()+ "'";
            }
        } catch (Exception e) {
            logger.error("Exception in getDealer Details(): ", e);  
        }
        
        return dao.getJobcardDetails(clause);
    

    }

}

dao实施-

@Override
    @Cacheable(value="getJobcardDetails",key = "#clause")
    public Object getJobcardDetails(String clause) throws Exception {
        String sql = QueryConstant.JOBCARD_DETAILS;
        sql = sql.replaceAll("#clause", clause);
        RowMapper<DealerResponse> rowMapper = new BeanPropertyRowMapper<DealerResponse>(DealerResponse.class);
        List<DealerResponse> list= jdbcTemplate.query(sql, rowMapper);
        if (list != null && list.size() > 0) {
            
            return list;
        }
        return null;
    }

'query constant'类,我在其中编写了从表中获取数据的查询-

public static final String JOBCARD_DETAILS = "select jc.*, dm.lat,dm.lng,l.icon as icon , l.color as color \r\n"
            +   "from jobcarddata jc   left outer join \r\n"
            + "dealer_mst dm on jc.dealer_code = dm.code left outer join    lookup l \r\n"
            + "on  dm.type = l.subcategory  #clause";

我从请求类中调用的json

{
    "region" :  "",
    "city" : "",
    "state" : "",
    "type" : "",
    "jctype" : "",
    "dealername" : ""

}

React变得无效-

"code": 1,
    "status": "SUCCESS",
    "statusMessage": "data found",
    "response": [
        {
            "name": null,
            "code": null,
            "address": null,
            "pincode": null,
            "city": null,
            "state": null,
            "region": null,
            "type": null,
            "contact_number": null,
            "lat": "26.7113",
            "lng": "80.8403",
            "status": "Active",
            "creation_date": null,
            "opentime": null,
            "closetime": null,
            "uniqueKey": null,
            "icon": "data:image/png;base64,iVBOR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ARkAjoBHQCGgENAIagfaOwH8B6Jy85/TKnOMAAAAASUVORK5CYII=",
            "color": "Blue",
            "jccount": null,
            "color_code": null,
            "oem": null,
            "jcNo": "4003143728",
            "jcopenDate": "20210714",
            "dealerName": "Narveda Motors",
            "dealerCode": "1S1212",
            "jcType": "ZUNR",
            "jsTypeDesc": "Running Repair",
            "jsStatus": "H065",
            "jsDesc": ""
        }
8zzbczxx

8zzbczxx1#

我从查询常量类中解决了这个问题,方法是从经销商主数据库中提取每一列,如下所示--

"select jc.*, dm.lat,dm.lng,l.icon as icon , l.color as color , dm.name , dm.code , dm.address , dm.pincode , dm.city , dm.state , dm.region , dm.type , dm.contact_number , dm.creation_date , dm.opentime , dm.closetime  \r\n"
            +   "from jobcarddata jc   left outer join"

相关问题