java - no error in code but its not working. it doesnt give right output -
//order bean //orderresponse bean //controller code //**********************************************insertupdateorder multiple********************************************************** @requestmapping(value="/insertupdateordermultiple", method = requestmethod.post) public @responsebody responseentity<orderresponse> insertupdateorder(@requestbody orderresponse orderresp){ if(orderresp.getorders() != null && orderresp.getorders().isempty()){ orderresponse orderresponse = salesdelegate.insertupdateorder(orderresp); system.out.println("beanobject"+orderresponse); if(orderresponse.getmessage().getstatuscode().tostring().equals("e203")){ return new responseentity<orderresponse>(orderresponse , httpstatus.not_acceptable); }else if(orderresponse.getmessage().getstatuscode().tostring().equals("e202")){ return new responseentity<orderresponse>(orderresponse,httpstatus.internal_server_error); }else { return new responseentity<orderresponse>(orderresponse,httpstatus.ok); } }else { return new responseentity<orderresponse>(httpstatus.not_acceptable); } } //delegate code public orderresponse insertupdateorder(orderresponse orderresponse) { system.out.println("orderdelegate"+orderresponse); return salesdao.insertupdateorder(orderresponse); } // dao code orderresponse insertupdateorder(orderresponse orderresp); //daoimpl code @override public orderresponse insertupdateorder(orderresponse order) { int id = -1; logger.info("in insertupdateorder multile"); orderresponse orderresp = new orderresponse(); message message = new message(); list<integer> orderid = new arraylist<integer>(); for(order lorder : order.getorders()){ try{ simplejdbccall jdbccall = new simplejdbccall(jdbctemplateobject). withprocedurename(kevanlasql.insert_update_order). declareparameters( new sqlparameter("aorderid",types.integer), new sqlparameter("acompanyid",types.integer), new sqlparameter("asubcategory_id",types.integer), new sqlparameter("asize",types.varchar), new sqlparameter("aprice",types.varchar), new sqlparameter("aquantity",types.varchar), new sqlparameter("adiscount",types.varchar), new sqlparameter("acustomerid",types.integer), new sqlparameter("alocationid",types.integer), new sqlparameter("aboy_id",types.integer), new sqlparameter("aproduct_id",types.integer), new sqlparameter("aphone",types.varchar), new sqlparameter("aaddress",types.varchar), new sqlparameter("astatus",types.varchar), new sqlparameter("apieces",types.varchar), new sqlparameter("aproduct_amount",types.varchar), new sqlparameter("adiscount_amount",types.varchar), new sqlparameter("atotal_amount",types.varchar), new sqloutparameter("param",types.integer) ); hashmap<string, object> input = new hashmap<string, object>(); input.put("aorderid", lorder.getorderid()); input.put("acompanyid", lorder.getcompanyid()); input.put("asubcategory_id", lorder.getsubcategory_id()); input.put("asize", lorder.getsize()); input.put("aprice", lorder.getprice()); input.put("aquantity", lorder.getquantity()); input.put("adiscount", lorder.getdiscount()); input.put("acustomerid", lorder.getcustomerid()); input.put("alocationid", lorder.getlocationid()); input.put("aboy_id", lorder.getboy_id()); input.put("aproduct_id", lorder.getproduct_id()); input.put("aphone", lorder.getphone()); input.put("aaddress", lorder.getaddress()); input.put("astatus", lorder.getstatus()); input.put("apieces", lorder.getpieces()); input.put("aproduct_amount", lorder.getproduct_amount()); input.put("adiscount_amount", lorder.getdiscount_amount()); input.put("atotal_amount", lorder.gettotal_amount()); input.put("param", ""); //system.out.println(input); id = (integer) jdbccall.execute(input).get("param"); if (id > 0){ orderid.add(id); } message.setstatuscode(statuscode.s201); message.setstatusmessage(statusmessage.success); } catch (emptyresultdataaccessexception erdae) { erdae.printstacktrace(); message.setstatuscode(statuscode.e202); message.setstatusmessage(statusmessage.fail); } catch (nullpointerexception n) { message.setstatuscode(statuscode.e203); message.setstatusmessage(statusmessage.fail); } catch (exception e) { message.setstatuscode(statuscode.e204); message.setstatusmessage(statusmessage.fail); } } orderresp=order; order.setmessage(message); order.setorderid(orderid); orderresp.setmessage(message); orderresp.setorderid(orderid); return orderresp; } //sql pakage call string insert_update_order = "insert_update_order"; //mysql procedure create definer=`root`@`localhost` procedure `insert_update_order`( in aorderid int, in acompanyid int, in asubcategory_id int, in asize varchar(250), in aprice varchar(250), in aquantity varchar(250), in adiscount varchar(250), in acustomerid int, in alocationid int, in aboy_id int, in aproduct_id int, in aphone varchar(250), in aaddress varchar(250), in astatus varchar(250), in apieces varchar(250), in aproduct_amount varchar(250), in adiscount_amount varchar(250), in atotal_amount varchar(250), out param int) begin if(aorderid=-1) insert orderdetails( companyid, subcategory_id, size, price, quantity, discount, customerid, locationid, boy_id, product_id, phone, address, status, pieces, product_amount, discount_amount, total_amount) values( acompanyid, asubcategory_id, asize, aprice, aquantity, adiscount, acustomerid, alocationid, aboy_id, aproduct_id, aphone, aaddress, astatus, apieces, aproduct_amount, adiscount_amount, atotal_amount); select max(orderid) aorderid orderdetails param; elseif(aorderid!=-1) update orderdetails set companyid = acompanyid, subcategory_id = asubcategory_id, size=asize, price=aprice, quantity= aquantity, discount=adiscount, customerid=acustomerid, locationid=alocationid, boy_id=aboy_id, product_id=aproduct_id, phone=aphone, address=aaddress, status=astatus, pieces=apieces, product_amount=aproduct_amount, discount_amount=adiscount_amount, total_amount=atotal_amount orderid = aorderid; set param := aorderid; end if; end // excepion in console 06-02-2016-06:02:16.369 [http-bio-8080-exec-9] debug o.s.web.servlet.dispatcherservlet - dispatcherservlet name 'dispatcherservlet' processing post request [/kevanlaappmobi/insertupdateordermultiple] 06-02-2016-06:02:16.369 [http-bio-8080-exec-9] debug o.s.w.s.m.m.a.requestmappinghandlermapping - looking handler method path /insertupdateordermultiple 06-02-2016-06:02:16.369 [http-bio-8080-exec-9] debug o.s.w.s.m.m.a.requestmappinghandlermapping - returning handler method [public org.springframework.http.responseentity<bee.kevanlaweb.mobiapp.messages.orderresponse> bee.kevanlaweb.mobiapp.crontroller.salescontroller.insertupdateorder(bee.kevanlaweb.mobiapp.messages.orderresponse)] 06-02-2016-06:02:16.369 [http-bio-8080-exec-9] debug o.s.b.f.s.defaultlistablebeanfactory - returning cached instance of singleton bean 'salescontroller' 06-02-2016-06:02:16.370 [http-bio-8080-exec-9] debug o.s.w.s.m.m.a.requestresponsebodymethodprocessor - reading [class bee.kevanlaweb.mobiapp.messages.orderresponse] "application/json" using [org.springframework.http.converter.json.mappingjackson2httpmessageconverter@2cb42334] 06-02-2016-06:02:16.370 [http-bio-8080-exec-9] debug o.s.w.s.m.m.a.responsebodyadvicechain - invoking responsebodyadvice chain body=null 06-02-2016-06:02:16.371 [http-bio-8080-exec-9] debug o.s.w.s.m.m.a.responsebodyadvicechain - after responsebodyadvice chain body=null 06-02-2016-06:02:16.371 [http-bio-8080-exec-9] debug o.s.web.servlet.dispatcherservlet - null modelandview returned dispatcherservlet name 'dispatcherservlet': assuming handleradapter completed request handling 06-02-2016-06:02:16.371 [http-bio-8080-exec-9] debug o.s.web.servlet.dispatcherservlet - completed request //postman
set orderid -1 when new order set particuler orderid want update
//request json { "orderid": -1, "companyid": 1, "subcategory_id": 1, "size": "m", "price":220, "quantity": "5", "discount": "10", "customerid": 1, "product_id": 1, "locationid": 1, "boy_id": 1, "phone":"1234567899", "address":"pune", "status": "1", "pieces":"20", "product_amount":"20", "discount_amount":"2", "total_amount": "200" } but not give success message/response didn't mistakes in code please me out code write api of getorders users. user gives data in json formate. please me out whats wrong in // request json url : http://localhost:8080/kevanlaappmobi/insertupdateordermultiple request method : post
if put break-point in controller's insertupdateorder method, , run application in debug mode, hit break-point when post? if not, can increase logging level spring mvc adding line application.properties file (assuming using spring boot).
logging.level.org.springframework.web=debug that might give clues.
also, hit f12 in browser , go network tab before post (assuming posting webpage). check posting correct url. also, check browser's console errors.
Comments
Post a Comment